View Full Version : calcuate between 2 dates


bma
06-08-2002, 01:26 AM
Any suggestion on calculating the difference between the two date (Start date & complete date) in days and months.

For example: Start date 1/1/2002, Complete date 10/3/2002. I expect the end result is 2 mths and 9 days.

Rich
06-08-2002, 01:54 AM
Search here for posts by Raskew, I'm certain he posted a function to do this, I think it was here.

raskew
06-08-2002, 03:14 AM
From the debug window try this:

startDte = #1/1/02#
endDte = #3/10/02#
numDays = DateDiff("d", startDte, endDte) + 1
? int(numDays / 30) & " months AND " & (numDays MOD 30) & " days"
2 months AND 9 days

This emulates the manual process of:

2002 03 10
(-)2002 01 01

02 09

Jon K
06-09-2002, 08:23 AM
Take a look at: www.mvps.org/access/datetime/date0001.htm (http://www.mvps.org/access/datetime/date0001.htm)

llkhoutx once directed me to this page. I find the code by Tim Walters to be very helpful. It is based on the exact number of days in each month.