How to Convert VarChar to DateTime in Sql Server 2005
Posted on 2011-10-20
I've recently imported data from MySQL into my SQL Server 2005 database.
One of the columns is named 'posted' which is saving the time period the record was created in the MySql table, although the Type of field is a Varchar(255), when i imported the data, I imported as Varchar into SQL Server 2005 to ensure no data type converting error occurred.
I now need to convert this to a datetime column type, the following is an example of how the data currently is stored:
1291734120 (the datetime this should reflect is 12/07/10 - 10:02)
1294417394 (the datetime this should reflect is 01/07/11 - 11:23)
1297970783 (the datetime this should reflect is 02/17/11 - 14:26)
1298927798 (the datetime this should reflect is 02/28/11 - 16:16)
1300120638 (the datetime this should reflect is 03/14/11 - 12:37)
Please help me convert the above Varchar in column 'posted' to an appropriate datetime field shown in the parenthesis above that i can use.