Calculating the difference between two seperate dates.

  • Thread starter Thread starter Charles Harris
  • Start date Start date
C

Charles Harris

I was just wondering how would I Calculate the difference
between two seperate dates, and after I have done so I
need that calculated date to be displayed in another
field.
 
You can calculate the difference in a calculated field in the query feeding
the report or in a calculated textbox in the report itself. The function is
DateDiff. You give it two dates and tell it how you want the results to show
(min, sec, hours, days, weeks, years, etc). There are a few things to know
though. For example, if you ask for years, then 31 DEC 2004 to 1 JAN 2005
will show as one year. So, it is usually better to have DateDiff calculate
to a smaller unit than what you're wanting (i.e. days instead of weeks or
years) then use that answer to compute the fractional portion if that's what
you're needing. It also has parameters for "first day of week" and "first
day of year".

To use in a calculated textbox on a report, the control source for the
textbox would look something like:

=DateDiff("d", [FirstDateField], [SecondDateField])
 
Back
Top