Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Nov 2003
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Varchar to Date SQL SERVER

    Hi folks, am a newbie to SQL server and finding it difficult to convert a varchar field to date (was easy in Access!)

    I have a field in Table1 called Opened which gives a string dd/mm/yyyy in varchar (10) format.

    I wish to convert this to date and have tried various methods all of which don't work. e.g.

    ALTERTABLE dbo.Table1
    ALTERCOLUMN OPENED date


    I have also tried CONVERT CAST without success.

    I'm sure its easy when you know how - can anyone help?

    Thanks so much

    blitz

  2. #2
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,518
    Thanks
    152
    Thanked 1,397 Times in 1,220 Posts
    You want to convert it to a Date to insert in a table or just to perform some calculation?

  3. #3
    Lounger
    Join Date
    Nov 2003
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ruirib View Post
    You want to convert it to a Date to insert in a table or just to perform some calculation?
    Hi I am going to search for records between dates.

    thanks.

  4. #4
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,518
    Thanks
    152
    Thanked 1,397 Times in 1,220 Posts
    You can use
    Code:
    convert(datetime, YourDateValueAsAString,103)
    


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •