I have a column in my database that is currently a varchar. the data looks like this:
Thu, 4 Jul 2013 09:18:24
Thu, 11 Jul 2013 10:07:01
Tue, 28 Jan 2014 11:38:37
Fri, 26 Jul 2013 14:13:42
I want to be able to convert that to a date so that I can get the most recent record.
Best How To :
SQL Server 2012 onwards, you can use
-- If the culture argument isn't provided, the language of current session is used.
SELECT TRY_PARSE('Thu, 4 Jul 2013 09:18:24' AS datetime2) AS 'datetime2';
TRY_PARSE: Returns the result of the expression, translated to the requested data type, or null if the cast fails.