TIME CALCULATING MACRO

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am looking for guidance on a macro which is to "set the value" of a field
in Year and Months and Days, as the time difference between two fields
entered as dates.
I would like to store this value in a format so that it can be searched at
another point, i.e. search for records where this value is greater than
2years etc.

Many thanks for taking the time to view this enquiry.

Rob
 
This could be very simple or pretty complex. It depends on if you want
rounded figures or exact actual months. For example, would you want your
macro to say that it has been 1 month when it went from feb 1 to march 1?
That would only be
28 days. If you don't mind rounding then here's the deal:

Take the difference of the serials of the dates. Divide by 365 for years.
Take the remainder and divide by 30 for months. Take the remainder for
number of days. Remainder can be found by the MOD function in VBA.

Hope that helps and God Bless.
 
The rounding is perfect, I am OK with the deviding by 365 and getting that
answer but I am unclear on how to divide the remainder in order to get a
correctly formed field.
MANY thanks,

Rob
 
Back
Top