issue with datetime

  • BWFC (9/26/2014)


    spectra (9/26/2014)


    >>>>Remove the CONVERT and you'll be doing the date range check you want.

    how do you convert 26/09/2014 to Date ?

    then you can use Cast(CreatedOn as date)

    No.......you misunderstood my query.... I meant ..how do I cast a String to date ?

    e.g Cast('9/26/2014' as date) ....Is it Ok ? Do I need to mention dd/mm/yyyy format here ? if so ..how ?

  • Now I really am confused, I'm definitely misunderstanding something.

    I thought CreatedOn was in the format yyyy-mm-dd hh:mm:ss.ttt. Where does the string come from?


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • spectra (9/26/2014)


    BWFC (9/26/2014)


    spectra (9/26/2014)


    >>>>Remove the CONVERT and you'll be doing the date range check you want.

    how do you convert 26/09/2014 to Date ?

    then you can use Cast(CreatedOn as date)

    No.......you misunderstood my query.... I meant ..how do I cast a String to date ?

    e.g Cast('9/26/2014' as date) ....Is it Ok ? Do I need to mention dd/mm/yyyy format here ? if so ..how ?

    SELECT CONVERT(datetime, '29/01/2014', 103)

  • >>>SELECT CONVERT(datetime, '29/01/2014', 103)

    what does 103 do here ?

  • It's the format code. See the CAST and CONVERT page in Books Online.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 5 posts - 16 through 19 (of 19 total)

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