Calculating difference between dates

C

Chi

Hi,

I use the formula below to calculate the difference between dates.
Difference: DateDiff("d",[InitialDate],[FirstF]). It works fine and gives me
the number of dates between two days like 35. However, I would like to have a
final result that shows month and date.

Ex: 35 days will be 1 month and 5 days.

Please help
Chi
 
J

Jeff Boyce

As far as I know, you get to (have to) do that yourself.

If you know "35" days, you could use division (divide by ?30, ?31, ?28, ??)
to get the integer number of months, then use the MOD function to get the
"remainder".

Good luck

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
M

Mr. B

First, to assume that "35 days will be 1 month and 5 days." is not a correct
assumption. You would need to know which month of which year, especially if
you are also going to calculate the months an days between two dates and
include February and it happened to be a leap year.

There is no simple answer to this. You can try to come up with the number
of days (just use what you are currently using). Then you will need to get
the month of the starting date and then decide what you consider to be a
month. Is it from the starting date to the same day of the next month, if so
you would need to calculate just how many days were between the two dates.
Then see if there are enough days to make another months calculation. Then
when you have deteremined the number of months, you will then need to
determine just how many days you have left over from the abve calculations.


-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page:
http://www.askdoctoraccess.com/DownloadPage.htm
 

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