Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 11 to 16 of 16 total |
Group By Hour from Timestamp |
Wed, Jun 17 2009 10:00 AM | Permanent Link |
"John Hay" | Roy
> IF( > EXTRACT(HOUR FROM _Timestamp) < 10 > THEN '0'+CAST(EXTRACT(HOUR FROM _Timestamp) AS VARCHAR(1))+':00 AM' > ELSE IF(EXTRACT(HOUR FROM _Timestamp) <=12 > THEN CAST(EXTRACT(HOUR FROM _Timestamp) AS VARCHAR(2))+':00 AM' > ELSE IF(EXTRACT(HOUR FROM _Timestamp)-12 < 10 > THEN '0'+CAST(EXTRACT(HOUR FROM _Timestamp)-12 AS VARCHAR(1))+':00 PM' > ELSE CAST(EXTRACT(HOUR FROM _Timestamp)-12 AS VARCHAR(2))+':00 PM'))) > AS RightFormat It would have been easier to quote the OP <vbg> ..... was hoping to find was a way to format the hour into something similar to "08:00" or "14:00". John |
Wed, Jun 17 2009 10:02 AM | Permanent Link |
"John Hay" | errrrr
must get some new glasses John |
Wed, Jun 17 2009 11:54 AM | Permanent Link |
Dar | Roy Lambert wrote:
Dar OK so you've pretty much got it from John's post. But here's the other bit you asked for CAST(CAST(EXTRACT(HOUR FROM TakenOn) AS VARCHAR(2))+':00' AS TIME) AS SnapHour Roy Lambert [Team Elevate] ====== Roy, Thanks a million for this, I think this might be what I need alright - thanks for your effort. Superb... Cheers.. Dar... |
Wed, Jun 17 2009 11:57 AM | Permanent Link |
Dar | Roy Lambert wrote:
Uli >which doesn't consider the format he wants: e.g. 02:00 p.m. errr <<format the hour into something similar to "08:00" or "14:00".>> But just to show willing IF( EXTRACT(HOUR FROM _Timestamp) < 10 THEN '0'+CAST(EXTRACT(HOUR FROM _Timestamp) AS VARCHAR(1))+':00 AM' ELSE IF(EXTRACT(HOUR FROM _Timestamp) <=12 THEN CAST(EXTRACT(HOUR FROM _Timestamp) AS VARCHAR(2))+':00 AM' ELSE IF(EXTRACT(HOUR FROM _Timestamp)-12 < 10 THEN '0'+CAST(EXTRACT(HOUR FROM _Timestamp)-12 AS VARCHAR(1))+':00 PM' ELSE CAST(EXTRACT(HOUR FROM _Timestamp)-12 AS VARCHAR(2))+':00 PM'))) AS RightFormat However, it won't sort/group correctly Roy Lambert [Team Elevate] ======= Roy, Fantastic, way above and beyond the call there. Thanks a mill again, that's great stuff. Cheers, Dar.. |
Wed, Jun 17 2009 5:16 PM | Permanent Link |
Ulrich Becker | Roy,
> errr > > <<format the hour into something > similar to "08:00" or "14:00".>> I referred to this one: << I need to create a query that produces something similar to : SnapDate SnapHour Count 06/16/09 08:00 AM 100 06/16/09 09:00 AM 23 06/16/09 10:00 AM 32 >> Anyway a productive discussion with detailed solutions. Uli |
Thu, Jun 18 2009 1:53 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ulrich
>I referred to this one: Oh I see - lost interest in the thread after the first post eh Roy Lambert |
« Previous Page | Page 2 of 2 | |
Jump to Page: 1 2 |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |