简体   繁体   中英

Date format in SQL Server 2008 R2

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM