Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a simple select query in my access database to fetch the record between two dates but the record output is null.

SELECT * FROM Stocksheet
WHERE  [Date1]>#22-07-13 3:22:58 PM# and [Date1]<=#24-07-13 3:22:58 PM#
ORDER BY Stocksheet.[Date1] DESC;


I have already checked by Between query but it is giving same output null. when i write the query

SELECT * FROM Stocksheet
WHERE  [Date1]<=#23-07-13 3:22:58 PM#
ORDER BY Stocksheet.[Date1] DESC;


Then it gives number of records. but i needs a filter data rows between two dates.
Posted
Updated 23-Jul-13 0:26am
v2
Comments
vinayoukuri 23-Jul-13 6:29am    
Please check your Date values(#7/13/2023 15:22:58#)they are same. the condition will return always null for such data.
[no name] 23-Jul-13 6:29am    
You need to check your logic on the first one. How can the date be less than and greater than the same date?

Try this (using BETWEEN ... AND ... statement):
SQL
SELECT * FROM Stocksheet
WHERE (Stocksheet.[Date1] BETWEEN #7/13/2023# And #7/13/2023#)
ORDER BY Stocksheet.[Date1] DESC;


I would suggest you to remove time part.
 
Share this answer
 
Comments
ankur15 23-Jul-13 6:31am    
Thanks for the answer but i have solve the query. there were a time format error
Maciej Los 23-Jul-13 6:33am    
So, you did what i suggest ;)
Please, mark the answer as "solved" (formally), use green button.
I have solve the problem. Time Format is not correct thats why it were not giving result.
 
Share this answer
 
SELECT * FROM Stocksheet
WHERE (Stocksheet.[Date1] BETWEEN #2013/07/22# And #2013/07/24#)
ORDER BY Stocksheet.[Date1] DESC;
 
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