This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes calculating difference between two dates in access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "calculating difference between two dates in access" Watch "calculating difference between two dates in access" New topic
Author

calculating difference between two dates in access

Hare Shiva
Greenhorn

Joined: Jul 08, 2012
Posts: 12
I have a table in which there is an attribute called SDate where i am storing Date.Now i need to select all rows from that table where the difference of current date and SDate is greater than 1 day.Please help me and also i think this problem is better solved if i add timestamp value.

select * from TeleQuery where DateDiff("d",SDate,Date())>1


If i use above query then rows with SDate 10/1/2012 doesnot get selected even though the difference between SDate and current Date 10/2/2012 is more than 1 day.Why is it not working?I am using access.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Seems to me that the difference between 10/1/2012 and 10/2/2012 is 1 day. And 1 is NOT greater than 1.

However I also think that your DateDiff function will return -1 for yesterday's date and not 1. Are you sure you have the two date parameters in the correct order?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calculating difference between two dates in access