Convert VarChar to DataTime

Total Post:46

Points:324
 1694  View(s)
Ratings:
Rate this:
I have a filed with VarChar in my table , I want to convert it in DateTime..

thanks
  1. Post:127

    Points:915
    Re: Convert VarChar to DataTime

    try this..
    SELECT convert(datetime, '1/12/2010', 212) -- mm/dd/yyyy

    SELECT convert(datetime, '2010.1.12', 214) -- yyyy.mm.dd


    cheers! 

      Modified On Oct-09-2010 04:24:40 AM
  1. Post:140

    Points:984
    Re: Convert VarChar to DataTime

    declare @s varchar(50)

    set @s = '2018-06-28 11:01:00' 

    select convert(varchar, cast(@s as datetime), 105) + RIGHT(@s, 9)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!