Convert Time to 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

  • 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/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply