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.
| Author |
Topic |
|
skillile
Posting Yak Master
208 Posts |
Posted - 2004-12-27 : 11:05:54
|
| what is a good way to round up minutes to half or whole hours.ie.select getutcdate() produces'12-27-2004 15:37:00'need to read '12-27-2004 16:00:00'or'12-27-2004 15:17:00'need to read '12-27-2004 15:30:00'or'12-27-2004 23:47:00'need to read '12-28-2004 00:00:00'slow down to move faster... |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-12-27 : 14:14:54
|
| You will need to write or find a custom date function for this. You will need a CASE statement to find your position, then build a date string based on datepart and your rounding logic. Make sense?MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-28 : 02:49:17
|
| declare @date datetimeset @date='12-27-2004 23:47:00'select case when datepart(minute,@date)>30 then dateadd(minute,60-datepart(minute,@date),@date) when datepart(minute,@date)>0 then dateadd(minute,30-datepart(minute,@date),@date) endwill this do? it 'ceilings' to 30 minutes--------------------keeping it simple... |
 |
|
|
|
|
|