Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
SQL
select USERID,checktime from CHECKINOUT where((CHECKTIME between 2012/06/01 and 2012/0630))order by CHECKTIME asc

This line of code doesn't retrieve any value. Can u send me any query that retrieve data between two dates.
Posted
Updated 20-Aug-12 1:10am
v2

You have 2012/0630 instead of 2012/06/30. Also, I believe dates should be in quotes.
 
Share this answer
 
Comments
bigyan sahoo 20-Aug-12 7:13am    
Thanks ,It works now
You have to put quotes around date values :
SQL
select USERID,checktime from CHECKINOUT where((CHECKTIME between '2012/06/01' and '2012/06/30'))order by CHECKTIME asc

To be more portable use '-' instead of '/' as some databases don't like '/' :
SQL
select USERID,checktime from CHECKINOUT where((CHECKTIME between '2012-06-01' and '2012-06-30'))order by CHECKTIME asc
 
Share this answer
 
Bigyan,

First question, are there data between the date range?

It looks like there's a typo in your till date, you're missing a /

Besides, there is no need for the braces.

SQL
SELECT USERID,checktime FROM CHECKINOUT WHERE CHECKTIME BETWEEN '2012/06/01' AND '2012/06/30' ORDER BY CHECKTIME ASC


Try this and let us know!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900