I have several columns of varchar(max) type that have either date or datetime data. I want to convert them to date type, which I know that I should use CONVERT function. Up to here is no problem!
ISSUE at my hand is that the dates stored in each column are not from similar date format type; not across columns and not even within one column. In other words, date format is not consistent within the column. Some of dates in one column may look like:
DDMMMYYYY
DD/MM/YYYY
MM/DD/YYYY
....
Using convert (without specifying the date style) will end up creating crazy outputs.
I need a script that converts these varchar to dates, preserving the original format.
I know the SET DATEFORMAT function; is there a reverse function that GET DATEFORMAT? Is there a way to detect the date format style?