October 31, 2013 at 11:47 am
I would like to change this date/time 7/22/2013 4:01:08 PM to 7/22/2013 12:00:00 AM
what would be the best way to convert or update the time portion only to 12:00:00 AM without changing it to a varchar?
Thanks
October 31, 2013 at 12:02 pm
There are some basic routines for datetime calculations.
Here's what you need.
SELECT DATEADD( DAY, DATEDIFF(DAY, 0, sampledate), 0)
FROM( SELECT CAST( '20130722 04:01:08PM' AS datetime) sampledate)x
And here are some more:
http://www.sqlservercentral.com/blogs/lynnpettis/2009/03/25/some-common-date-routines/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply