Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Rounding hour and minute from time stamp to the closest hour - response (3) by M.Saeed Khurram

$
0
0

Try this:

SELECT   CURRENT_TIME(0), 
CASE WHEN EXTRACT(MINUTE FROM CURRENT_TIME(0)) - 30   >= 0 
                    THEN CURRENT_TIME(0) + ((60 - EXTRACT(MINUTE FROM CURRENT_TIME(0))) * INTERVAL  '1' MINUTE)
               ELSE CURRENT_TIME(0) -  EXTRACT(MINUTE FROM CURRENT_TIME(0))  * INTERVAL  '1' MINUTE
END  AS Converted_Time
,Converted_Time - TIME '00:00:00' HOUR TO MINUTE AS Rounded_Time;

 

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>