SQL query to select dates between two dates

后端 未结 22 1374
囚心锁ツ
囚心锁ツ 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:46

    we can use between to show two dates data but this will search the whole data and compare so it will make our process slow for huge data, so i suggest everyone to use datediff:

    qry = "SELECT * FROM [calender] WHERE datediff(day,'" & dt & "',[date])>=0 and datediff(day,'" & dt2 & "',[date])<=0 "
    

    here calender is the Table, dt as the starting date variable and dt2 is the finishing date variable.

提交回复
热议问题