DateDiff

AmandaBurlingham

Registered User.
Local time
Today, 20:24
Joined
Aug 25, 2009
Messages
12
Hi, I am new to this site but i have a problem which is driving me mad as i think the solution is so easy!!...

I have two fields in my table/form - TR_DateExpires and TR_DaysLeftUntilExpired...... I want to have TR_DaysLeftUntilExpired automatically calcualted ie how many days left between now and the expiry date. I thuink this will then be easy to run queries showing things expiring in say 30 days, 60 days and 90 days. It would be even better if it showed the time left before expiry as years, months and days but at the moment i would just be happy with number of days! Any help so greatfully appreciated! :o
 
Datediff is the correct function to use you can tell it to calculate the elapsed time in many ways from seconds to years. Do an Access search on DateDiff for a more clearer explanation.

David
 
Hi, i am obviously missing something as i still can't figure it out! :-(
 
Oh god...please help - i have tried so much.... here is where i am and it still won't work!!! DateDiff("d","TR_DateExpires","Date()"[vbMonday],[vbFirstJan1])
 
DateDiff("d",TR_DateExpires,Date())

Only the first argument is a string so no quotes on the others. The other arguments are are optional and defaults will be used.

Since it is days you are working with you can simply subtract dates. Dates are acutally stored as numbers of days. Times are fractions of a day.

This will do it:
TR_DateExpires - Date()
 

Users who are viewing this thread

Back
Top Bottom