COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: pooja on 15 Jan 2010 02:37:07 PM

Title: days in decimal form
Post by: pooja on 15 Jan 2010 02:37:07 PM
how to get no of days differernce in decimal form, ..
say--12.75 days

from 2010-01-13;00.00.00
to 2010-01-01;04:55;12

thank you
Title: Re: days in decimal form
Post by: blom0344 on 16 Jan 2010 08:53:25 AM
You're on DB2 aren't you? (from earlier post by almost the same name) Did you check SQL cookbooks for a native solution?
There is a specific TIMESTAMPDIFF function available in DB2.

By the way , you are refering to Timestamps , not Days in your example
(and why not keep all your issues concerning date calculations within the same post?)
Title: Re: days in decimal form
Post by: blom0344 on 18 Jan 2010 03:31:14 AM
Elaborate, but the following seems to work:

[precision down to seconds]:


extract(day;current_timestamp  - _make_timestamp (2010;01;18))*24*3600+
extract(hour;current_timestamp  - _make_timestamp (2010;01;18))*3600+
extract(minute;current_timestamp  - _make_timestamp (2010;01;18))*60+
extract(minute;current_timestamp  - _make_timestamp (2010;01;18))


returns integer for value as differnce in seconds between timestamps