Difference Between 2 Dates

gracm25

Registered User.
Local time
Today, 12:05
Joined
Dec 6, 2007
Messages
31
Hello,

Same song, different dance. I'm trying to calculate the difference between the last safety incident at each of our branches and the current date (want to know how long each branch has gone without an injury). I've written individual queries to pull out each branches max injury date, but when I try to use the expression builder to enter this phrase, I just the game #NAME# error. Please see below and offer any advice. Thanks!!

=DateDiff("d",Max([qryMostRecentSafetyViolationMemphisBranch]![DATE_OF_INCIDENT]),Date())

I also wrote it this way and got the same error:

=DateDiff("d",qryMostRecentSafetyViolationMemphisBranch!MaxOfDATE_OF_INCIDENT,Date())
 
Would this work?
Expr1: Date()-[IncidentTable]![Last incident]

Being placed in as a new field on your query
 
Thanks, Access_guy49. It does work, but only if there is one date in the query. If there are several safety incidents at a branch over time, I want to be able to pull the most recent one and calculate how long it's been since that time up to the current date.

Do you think I could still pull the expression you wrote below, but just pull the max from that and put it in the form?

Thanks again!
 
You said you already have a query that pulls the most recent incident right? so you could use that query couldn't you?
instead of:
Expr1: Date()-[IncidentTable]![Last incident]
Use
Expr1: Date()-[Last incident Query]![Incident date]
I think that would probably work
 
Hello,

Same song, different dance. I'm trying to calculate the difference between the last safety incident at each of our branches and the current date (want to know how long each branch has gone without an injury). I've written individual queries to pull out each branches max injury date, but when I try to use the expression builder to enter this phrase, I just the game #NAME# error. Please see below and offer any advice. Thanks!!

=DateDiff("d",Max([qryMostRecentSafetyViolationMemphisBranch]![DATE_OF_INCIDENT]),Date())

I also wrote it this way and got the same error:

=DateDiff("d",qryMostRecentSafetyViolationMemphisBranch!MaxOfDATE_OF_INCIDENT,Date())

You might try :
=DateDiff("d",[DATE_OF_INCIDENT],Date())
 
I think I'm confusing myself. Not too hard to do, but nonetheless....

The query that pulls the last incident date is just a query based on branch number and ALL incident dates, but has a "Max" in the "Total" criteria field. So, if I ran the query, it would pull the specific branch I wanted and the most recent date. However, when I try to reference that query in the form using the DateDiff function, it just gives me the #NAME# error. I just can't figure out why I can pull it out of a query, but can't display it in a form.

I also tried your suggestions below and they also gave me the same errors.

Thanks for the help.
 

Users who are viewing this thread

Back
Top Bottom