COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: pooja on 19 Jan 2010 09:51:10 PM

Title: average date
Post by: pooja on 19 Jan 2010 09:51:10 PM
I have posted couple of issues related with dates.I am looking to way out for this calculation--
I have calculated timestamp diff and come up this kind o results

example----
123 days 28 hrs 45min 10sec

now I trying to change this into decimal, ex 123.17 days

Please need advice/suggestion/solution kindly appreciated.

thank you in advance
Title: Re: average date
Post by: blom0344 on 20 Jan 2010 03:37:34 AM
From an earlier post I suggested a solution that would give you the difference as an integer value. If that approach works then it would be just a matter of performing a division by a fixed constant to get that number of days like  123.17

example:

_round((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)))/86400;4)

In this example current time is compared with a generated timestamp (earliest second on 2010-01-18)
According to my output this generates the exact difference in days