What is SQL Query to get dates between two dates?


Hello, I have one more question related to SQL query, in which I would like to know how can I get all dates between two dates using SQL Query. For example, I have start date = 10/02/2022 and end date = 14/02/2022, then query must return dates 11/02/2022, 12/02/2022 and 13/02/2022.

I am using SQL Server for this, but I think SQL query will remain the same for oracle or MySQL too.


Asked by:- neena
0
: 2604 At:- 2/23/2022 11:26:23 AM
SQL date between two dates sql







1 Answers
profileImage Answered by:- bhanu

You can simply use below query to get dates between two dates

select * from TableName where Id = 1
             and Date >= '2022/02/10' and Date <= '2022/02/14'

OR

select * from TableName where Id = 1
            and Date between '2022/02/10' and '2022/02/14'

In the above queries, we are not considering time-part.

2
At:- 2/23/2022 2:00:03 PM
Thanks for the answer, looks to be working fine 0
By : neena - at :- 3/29/2022 3:29:25 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use