Reputation: 329
I'm having a UI in which there are two date fields, start date and end date, when user selects a date range, the data from the end date is not displayed. the query for date filtering is :
select * from dataTable where dateval between startdate and enddate.
So if i select startdate=1st June 2014 and enddate=12th June 2014, it wont display the records on the 12th of June. Please help.
Upvotes: 0
Views: 120
Reputation: 6651
Although it's not explicitly stated, your columns include hour, minute, and second information.
What is likely happening is your query is being read by the database as all values >= 1 Jun 2014 00:00:00
and <= 12 Jun 2014 00:00:00
You may wish to specify the time information, or try converting the datetime
to a format that truncates the time information, then the query should work as expected:
select * from dataTable where convert(char(10),datval,101) between "06/01/2014" and "06/12/2014"
Upvotes: 1