Date format in SQL Server 2008 R2

早过忘川 提交于 2019-12-11 07:16:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!