|
-
Jul 6th, 2007, 08:16 AM
#1
Thread Starter
Lively Member
Rounding time seconds up in SQL Server
Have two time values
1900-01-01 00:59:47.000 need to round up to
1900-01-01 01:00:00.000
1900-01-01 00:19:23.000 need to round down to
1900-01-01 00:19:00.000
Perferably using a function or something that does both on the same column!
Note the date above is the difference between as startdate and a enddate!
thanks
rag
-
Jul 6th, 2007, 12:27 PM
#2
Re: Rounding time seconds up in SQL Server
I think you'd have to write your own function to do that.
-
Jul 6th, 2007, 03:18 PM
#3
Re: Rounding time seconds up in SQL Server
Simply Converting/Casting datetime values to smalldatetime will perform the "rounding" you desire.
Declare @StartDate datetime
Set @StartDate = '1900-01-01 00:59:47.000'
Print Cast(@StartDate as smalldatetime)
Set @StartDate = '1900-01-01 00:19:29.000'
Print Cast(@StartDate as smalldatetime)
Jan 1 1900 1:00AM
Jan 1 1900 12:19AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|