February 4, 2011 at 3:42 pm
I have this string date format, cant change it, in an export file..
1/02/2011 12:03:41 p.m.
1/02/2011 11:59:00 a.m.
HOw does one convert this data date time string to TSQL DATETIME ??
Thanks
February 4, 2011 at 3:52 pm
select
a.*,
DT = convert(datetime,replace(a.StrDt,'.',''))
from
( -- Test Data
select StrDt = '1/02/2011 12:03:41 p.m.'
union all
select StrDt = '1/02/2011 11:59:00 a.m.'
) a
Results:
StrDt DT
----------------------- -----------------------
1/02/2011 12:03:41 p.m. 2011-01-02 12:03:41.000
1/02/2011 11:59:00 a.m. 2011-01-02 11:59:00.000
February 4, 2011 at 4:04 pm
wow Thanks !:-)
February 7, 2011 at 7:34 am
Lookup Convert() in Books Online. Using the format codes will assist you greatly.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply