SQL query to select dates between two dates

后端 未结 22 1683
囚心锁ツ
囚心锁ツ 2020-11-22 09:10

I have a start_date and end_date. I want to get the list of dates in between these two dates. Can anyone help me pointing the mistake in my query.<

22条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 09:30

    you should put those two dates between single quotes like..

    select Date, TotalAllowance from Calculation where EmployeeId = 1
                 and Date between '2011/02/25' and '2011/02/27'
    

    or can use

    select Date, TotalAllowance from Calculation where EmployeeId = 1
                 and Date >= '2011/02/25' and Date <= '2011/02/27'
    

    keep in mind that the first date is inclusive, but the second is exclusive, as it effectively is '2011/02/27 00:00:00'

提交回复
热议问题