Datetime in where clause

前端 未结 6 859
终归单人心
终归单人心 2020-12-13 08:15

How can I select 12/20/2008 in where clause of sql?

The server is SQL server 2005.

select * from tblErrorLog
where errorDate = \'12/20/2         


        
6条回答
  •  囚心锁ツ
    2020-12-13 08:49

    You don't say which database you are using but in MS SQL Server it would be

    WHERE DateField = {d '2008-12-20'}
    

    If it is a timestamp field then you'll need a range:

    WHERE DateField BETWEEN {ts '2008-12-20 00:00:00'} AND {ts '2008-12-20 23:59:59'}
    

提交回复
热议问题