Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Location
    UK
    Posts
    233

    Unanswered: Convert VarChar to DateTime

    Ok I thought this would be easy. How foolish of me.

    I have a table with a field called StartDate(nVarChar(50)). This field is populated from an imported csv file.

    After the data is imported I want to move the data from that table to another and convert the StartDate(nVarChar) field to DateTime.

    TableOne.StartDate(nVarChar(50)) = dd/mm/yyyy hh:mm or 22/09/2010 10:40

    I need to Insert this into

    TableTwo.StartDate(DateTime) = dd/mm/yyyy hh:mm or 22/09/2010 10:40

    Thanks

  2. #2
    Join Date
    Sep 2010
    Posts
    19
    see if this help you ,
    -- Convert string to datetime sql - convert string to date sql - sql dates format

    -- T-SQL convert string to datetime - SQL Server convert string to date

    SELECT convert(datetime, '10/23/2016', 101) -- mm/dd/yyyy

    SELECT convert(datetime, '2016.10.23', 102) -- yyyy.mm.dd

    SELECT convert(datetime, '23/10/2016', 103) -- dd/mm/yyyy

    SELECT convert(datetime, '23.10.2016', 104) -- dd.mm.yyyy

    SELECT convert(datetime, '23-10-2016', 105) -- dd-mm-yyyy

  3. #3
    Join Date
    May 2003
    Location
    UK
    Posts
    233
    Perfect
    Thank you kindly Sir

  4. #4
    Join Date
    Sep 2010
    Location
    San Jose, CA
    Posts
    1
    Thanks, memo2010 that's helped me out with my date conversions too.
    I've made a copy of those date formats for future use!

Posting Permissions

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