Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Round to the nearest hour

Author  Topic 

velvettiger
Posting Yak Master

115 Posts

Posted - 2012-10-17 : 15:39:23
Hi Everyone,

I would like to how to roundup the time for a date/time value.

e.g 7:30am would be shown as 8:00am. Below I had to format the time fields but I am not sure how to incorporate the round() function.



DECODE(
TO_CHAR
(
TO_DATE
(SSRMEET_BEGIN_TIME,'HH24:MI'),'HH:MI pm'
)||'-'||
TO_CHAR
(
TO_DATE
(SSRMEET_END_TIME,'HH24:MI'),'HH:MI pm'
),'-','TBA',
TO_CHAR
(TO_DATE
(SSRMEET_BEGIN_TIME,'HH24:MI'),'HH:MI pm'
)||'-'||
TO_CHAR
(
TO_DATE
(SSRMEET_END_TIME,'HH24:MI'),'HH:MI pm'
)
)

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-10-17 : 15:40:49
SQLTeam is a Microsoft SQL Server website. Oracle questions can be posted at http://dbforums.com/
Go to Top of Page
   

- Advertisement -