sql server - How to convert text column to datetime in SQL -
i have column that's text:
remarks (text, null)
a sample value "5/21/2013 9:45:48 am"
how convert datetime format this: "2013-05-21 09:45:48.000"
the reason conversion trying total number of hours between datetime column , date stamp in remarks column. thinking of this:
remarks (text, null) - date_sent (datetime, null)
to clear, columns represent datetime inquiry customer sent (date_sent) , last response made representative regarding inquiry (response), sample of date_sent having value of "2013-05-21 08:00:00.000" , response value of "5/21/2013 10:00:00 am", should value of 2.00 (2 hours). unfortunately, in database i'm working on, remarks text , date_sent datetime.
i'm kind of new sql, need on :( tia!
use convert style 101.
select convert(datetime, remarks, 101)
if column text
need convert varchar before converting datetime
select convert(datetime, convert(varchar(30), remarks), 101)
Comments
Post a Comment