Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 4 of 4 total |
Rounding Timestamp to nearest hour |
Tue, Oct 8 2013 2:33 PM | Permanent Link |
Rolf Nilsson | Hi,
I have a generated Integer column where I try to calculate number of hours from two Timestamp columns like this: ALTER COLUMN "TimeCount" AS INTEGER GENERATED ALWAYS AS CAST((Date2 - Date1) AS INTERVAL HOUR) This works, but now I have to round the result to nearest hour, something like this: ALTER COLUMN "TimeCount" AS INTEGER GENERATED ALWAYS AS ROUND(CAST((Date2 - Date1) AS INTERVAL MINUTE) / 60) This doesn't work obviously. any advice is most Welcome. Best regards, Rolf |
Tue, Oct 8 2013 5:43 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Rolf,
<< ALTER COLUMN "TimeCount" AS INTEGER GENERATED ALWAYS AS ROUND(CAST((Date2 - Date1) AS INTERVAL MINUTE) / 60) This doesn't work obviously. >> Use this: ALTER COLUMN "TimeCount" AS INTEGER GENERATED ALWAYS AS ROUND(CAST(CAST((Date2 - Date1) AS INTERVAL MINUTE) AS INTEGER) / 60) Tim Young Elevate Software www.elevatesoft.com |
Wed, Oct 9 2013 7:54 AM | Permanent Link |
Rolf Nilsson | On 2013-10-08 23:43, Tim Young [Elevate Software] wrote:
> Use this: > > ALTER COLUMN "TimeCount" AS INTEGER GENERATED ALWAYS AS > ROUND(CAST(CAST((Date2 - Date1) AS INTERVAL MINUTE) AS INTEGER) / 60) Thanks Tim, that did it! By the way, Intervals is not easy to understand. Would be nice with a good educational article on the subject |
Thu, Oct 10 2013 3:22 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Rolf,
<< By the way, Intervals is not easy to understand. Would be nice with a good educational article on the subject >> Yes, definitely. I hope to get some time to start adding some more technical articles soon. Thanks, Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Sunday, May 5, 2024 at 10:18 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |