If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

extract function in reportnet

Started by uyravikumar, 28 Jul 2006 03:31:49 AM

Previous topic - Next topic

uyravikumar

Hi All,

I am working on a project, i have problem with extract function.

I need to display the Hours:Minutes:Seconds of difference from two dates which is placed in on data item [TIMEDIFF].

I used
CAST(EXTRACT(HOUR,[TIMEDIFF]),VARCHAR(2))||':'||
CAST(EXTRACT(MINUTE,[TIMEDIFF]),VARCHAR(2))||':'||
CAST(EXTRACT(SECOND,[TIMEDIFF]),VARCHAR(2))


The output is 0:34:14. (OR) 0:33:23.3

I want to get the second part as Integer.

Can any body help me..

Thanks in advance

MFGF

Hi,

You could change you calculation thus:

CAST(EXTRACT(HOUR,[TIMEDIFF]),VARCHAR(2))||':'||
CAST(EXTRACT(MINUTE,[TIMEDIFF]),VARCHAR(2))||':'||
CAST(FLOOR(EXTRACT(SECOND,[TIMEDIFF])),VARCHAR(2))

Alternatively, for better efficiency, you could do the following:

Create a calculation for each time part

EXTRACT(HOUR,[TIMEDIFF])    - call this HR
EXTRACT(MINUTE,[TIMEDIFF])   - call this MT
FLOOR(EXTRACT(SECOND,[TIMEDIFF]))    - call this SC

In Report Studio, press the padlock button (unlock) to unlock the structure of your list.

Drag the MT and SC calculations into the same column as HR, then from the toolbox drag a text item between
and [MT] and type a colon (:).  Do the same between [MT] and [SC].

Press the padlock button again to relock, and you're all done - you should now have a displayed column in the format Hours:Minutes:Seconds, but with no data type translations required, improving efficiency.

Hope that helps,

MF.
Meep!