need help to convert nvarchar(255) 30-07-2007 to a datetime 2007-07-30 format

  • Hi I need help to convert a field (nvarchar(255), null) for example 30-07-2007 to datetime 2007-07-30.

    Thanks for your help.

  • Something along the lines of

    Select convert(datetime, N'30-07-2007', 105)

  • sorry, I am getting in this format, Jan 11 2006 12:00AM which is not right.

    any idea?

  • the example converts string to datetime...then if you want a specific format, you've got to convert it back again:

    --Results

    /*

    2007-07-30

    */

    Select convert(varchar(10),convert(datetime, N'30-07-2007', 105) ,120)

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • It worked.Thanks a lot!

Viewing 5 posts - 1 through 4 (of 4 total)

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