Author Topic: extract function in reportnet  (Read 820 times)

Offline uyravikumar

  • Full Member
  • ***
  • Posts: 17
  • Forum Citizenship: +0/-0
extract function in reportnet
« on: 28 Jul 2006 02:31:49 am »
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

Offline MFGF

  • Never knowingly correct
  • Super Moderator
  • Statesman
  • ******
  • Posts: 3,112
  • Forum Citizenship: +153/-3
  • Cognos Software Muppet
Re: extract function in reportnet
« Reply #1 on: 28 Jul 2006 05:21:26 am »
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!