datediff problem

G

Guest

I am using Datediff function to calculates how many months are between dates.
But I have found that the function only counts the months and not the actual
dates.
e.g. 1/24/06 and 2/4/06 will yield 1(one) even though it is really 0(aero).

I use Int(Datediff("d", xdate, ydate) / 30). However, this isn't really
that accurate when Feb and the months with 31 days are considered. Any other
suggestions would be appreciated.

Mike
 
R

Rick Brandt

mjj4golf said:
I am using Datediff function to calculates how many months are
between dates. But I have found that the function only counts the
months and not the actual dates.
e.g. 1/24/06 and 2/4/06 will yield 1(one) even though it is really
0(aero).

I use Int(Datediff("d", xdate, ydate) / 30). However, this isn't
really that accurate when Feb and the months with 31 days are
considered. Any other suggestions would be appreciated.

Mike

DateDiff() counts "boundaries crossed" so 1 is the correct response for
DateDiff("m", #1/24/06# , #2/4/06#).

What result are you looking for? How many whole months or do you want to round
at the mid-month? Often with DateDiff you have to return a smaller increment
than you want and then do some more math on that.
 
G

Guest

I am looking for the correct value between two dates.
e.g. a one(1) would be returned for dates #1/24/2006# and #2/24/2006#

Mike
 

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

Similar Threads


Top