I want to put the “days between” in my universe rather than in my report. I am using DB2. I can use the “days” command and calculate that as a number. That’s good…but not good enough!
I need to calculate the days between two date/timestamps. My result should account for the hours, minutes, and seconds between the operations. Any suggestions on how to get this to the accuracy level I need?
Sounds like an implicit Data Type conversion. Without the decimal point the DBMS considers the result set to be INTEGER (-1, 0, 1 , 2, 3,…), with the decimal point it converts it behind the scenes to data type REAL (-1.23, 0.0, 5.74, …).
Alright - I was avoiding this but could no longer contain myself.
I don’t understand all the contortions you are going thru. My little DB2 SQL reference say that timestamp durations (subtracting) return DEC(20,6) format – that format is ccyymmddhhmmss.micros. I would do the subtraction and then parse out whatever part of that you need.
Date durations return DEC(8,0) as yyyymmdd so subtracting a birthdate from current date might give you 000410530 or 41 years, 5 months, 30 days.
But then I may be wrong cause I always have to look this stuff up and figure it all out again.
What I was trying to do was to get the elapsed time in days…the system I’m working on in Delivery Performance so they want to see all kinds of date/timestamps subtracted from one another to get the duration of an activity. I needed to get it in days…to the 1/100th of the day.
If there’s a better way, let me know…this was what my warped little mind came up with…
I needed to figure out how to turn five months, two days, seventeen hours, and thirty minutes into 154.76 days…