January 9, 2012 at 6:54 pm
Hi
I have an issue with rounding. I have an int column that holds a number of seconds. I need to be able to round this up to the nearest 60 seconds. In all cases this needs to be a round up and not a round.
Apologies if in the wrong area etc of this forum, first time posting an issue.
Thanks
Scott
January 10, 2012 at 2:07 am
This should do:
WITH SampleData (seconds) AS (
SELECT 1
UNION ALL
SELECT 110
UNION ALL
SELECT 65
)
SELECT roundedUpSeconds = 60 * CEILING(CAST(seconds AS decimal(18,6)) / 60)
FROM SampleData
Hope this helps
Gianluca
-- Gianluca Sartori
January 10, 2012 at 8:56 pm
Worked a Treat.. Thanks for your help Gianluca.
January 11, 2012 at 3:18 am
You're welcome.
Glad I could help.
-- Gianluca Sartori
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply