Date in String format to be changed to right format

  • I have date coming to one page as a string in the following format

    "May 4 2005 12:00AM"

    I need to query one of my tables using this date in combination of other nondate values. How can I convert this date into valid sql server datetime format before I query a database tables

    Please help

     

  • I do not know if the double quotes are used to show us the format or if they are actually passed into SQL Server.  If you can replace them with single quotes, it is a fairly straightfoward conversion: 

    SELECT CONVERT( datetime, 'May 4 2005 12:00AM') 

    Hope this helps...

    I wasn't born stupid - I had to study.

  • I don't think you need to convert it since this would work just fine.


    Select *

    From YourTable

    Where YourDateColumn = 'May 4 2005 12:00AM'


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

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