Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in SQL by (20.3k points)

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.

select Date,TotalAllowance 

from Calculation 

where EmployeeId=1

  and Date between 2011/02/25 and 2011/02/27

Here Date is a datetime variable.

1 Answer

0 votes
by (40.7k points)
edited by

To get the dates between two dates you need to follow the following process:

You need to put those two dates between single quotes in this way:

SELECT Date, TotalAllowance 

FROM Calculation 

WHERE EmployeeId = 1 and Date between '2011/02/25' and '2011/02/27'

Are you interested in learning SQL from the basics! Refer to this video on SQL provided by Intellipaat:

Or, you can use the below code:

SELECT Date, TotalAllowance 

FROM Calculation 

WHERE EmployeeId = 1 and Date >= '2011/02/25' and Date <= '2011/02/27'

You can learn in-depth about SQL statements, queries and become proficient in SQL queries by enrolling in our industry-recognized SQL course.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...