converting char to datatime
-
in my source table i have '1530' as char data type which is actually a time (HHMM) in my destination table the column is datetime. how could i convert '1530' and insert into destination table of type datetime. please help
Hey there! It is a bit hard to convert it to dateTime from just 24hrs Time format. From the little knowledge you have, you could play around with the following syntax but I am sure that it won't return you the proper result. Syntax: convert(varchar(24),cast(1530 as datetime),8) It would be wise to just do it on the front end if you are using it. In C#, you can achieve this by: DateTime _dteDateTime = Convert.ToDateTime("1530").ToString("hh:mm"); If you are using VB.Net, I think the syntax was: FORMAT(Node, "yyyy-mm-dd") Hope that this helps. ------------------------------------------------------------------------ If there was no SQL, there would be no sequels to programming.