Jays Jays - 7 months ago 78
SQL Question

SQL date order by

I have two kind of date format in my table now I want to show the date as order by.

The results look like this:

screenshot of column values

I want to display the records in ascending format in single format

Any help would be really appreciated


In SQL Server, it is easiest to convert strings using the built in convert() formats. This is a big inconvenience. You can try:

order by coalesce(try_convert(datetime, meeting_status_date),
                  try_convert(datetime, meeting_status_date, 0),
                  try_convert(datetime, meeting_status_date, 101)

try_convert() returns NULL if the conversion fails. The list of conversion formats is here.