Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

calculating difference between two dates in access

 
Hare Shiva
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!