TIME CALCULATING MACRO

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
 
C

Cubs_Rule!

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top