Convert time interval to units of hours | Will Holtz | 2015-12-14 09:38 |
Status: Closed | ||
Hi Jon, Thanks for the reply. Here are some related things I've tried without success: SELECT timestampdiff('SQL_TSI_HOUR', to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('05 Dec 2000 02:33', 'DD Mon YYYY HH24:MI')) AS tsdiff01, timestampdiff('SQL_TSI_HOUR', to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('08 Dec 2000 02:33', 'DD Mon YYYY HH24:MI')) AS tsdiff02, timestampdiff('SQL_TSI_HOUR', to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('08 Dec 2004 02:33', 'DD Mon YYYY HH24:MI')) AS tsdiff03, age(to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('05 Dec 2000 02:33', 'DD Mon YYYY HH24:MI'))*365*24 AS tsdiff04, age(to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('08 Dec 2000 02:33', 'DD Mon YYYY HH24:MI'))*365*24 AS tsdiff05, age(to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('08 Dec 2004 02:33', 'DD Mon YYYY HH24:MI'))*365*24 AS tsdiff06, age(to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('05 Dec 2000 02:33', 'DD Mon YYYY HH24:MI'), 'SQL_TSI_YEAR')*365*24 AS tsdiff07, age(to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('08 Dec 2000 02:33', 'DD Mon YYYY HH24:MI'), 'SQL_TSI_YEAR')*365*24 AS tsdiff08, age(to_timestamp('05 Dec 2000 01:13', 'DD Mon YYYY HH24:MI'), to_timestamp('08 Dec 2004 02:33', 'DD Mon YYYY HH24:MI'), 'SQL_TSI_YEAR')*365*24 AS tsdiff09 FROM core.users; The outputs I get with Postgres v9.3.4.2 and Labkey v15.3 are: 1.0, 1.0, 1.0, 0.0, 0.0, 35040.0, 0.0, 0.0, 35040.0 I really don't understand the outputs of timestampdiff() in my example and it appears that age() rounds or truncates to an integer number of years, so it is not useful for me. Additionally, the Labkey SQL docs state, 'Postgres does not support using timestampdiff on intervals larger than day,' and my use requires intervals larger than a day. (An aside, the Labkey SQL docs list that note about timestampdiff() along side the information about the age() function and not adjacent to the documentation for timestampdiff()) Other ideas? thanks, -Will |
||