0 votes
1 view
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.3k 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'

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...