问题
How to cast date for the following format in SQL Server 2008 R2:
Date:
'29-01-2008 AM 12:00:00'
I have above date to check with the present date of the table.
How can I check only date from the above format?
回答1:
If you want only the date, then do:
select convert(date, left('29-01-2008 AM 12:00:00', 10), 105)
This will convert it to a date and you can then compare it to `cast(getdate() as date).
The full list of formats for convert() is in the documentation.
来源:https://stackoverflow.com/questions/25869271/date-format-in-sql-server-2008-r2