how to query where date with time = date without time in ms sql

前端 未结 4 2040
臣服心动
臣服心动 2021-02-06 02:33

I want to do a query with dates this is my sample tsql:

select * from Bookings where StartTime = \'2/15/2014\'

the starttime has value \'2/15/2

4条回答
  •  抹茶落季
    2021-02-06 02:35

    '2/15/2014' can be interpreted different depending on your locale. Try using the ISO date literal '2014-02-15', which is independent of the locale.

    select * from Bookings where StartTime = '2014-02-15'
    

    Or if StartTime includes hours:

    select * from Bookings where StartTime >= '2014-02-15' and StartTime < '2014-02'16'
    

提交回复
热议问题