How to get the difference of the month from the date specified.
Example:

date1.value="5/1/2010"
date2.vale ="5/31/2011"

it should give a result of 12.

thank you for helping.!

Edited 5 Years Ago by blocker: n/a

Dim resultdate As Long

        resultdate = DateDiff(DateInterval.Year, date2, date1)

Try this...

Sorry u need months right? try this

resultdate = DateDiff(DateInterval.Month, date1, date2)

Sorry u need months right? try this

resultdate = DateDiff(DateInterval.Month, date1, date2)

Thanks. But i got these error!

"Object required" even if the name of the date control is correct..

msgbox datediff(dateinterval.month,dt1.value,dt2.value)

Thanks. But i got these error!

"Object required" even if the name of the date control is correct..

msgbox datediff(dateinterval.month,dt1.value,dt2.value)

I got it.. These works!

dim getmonthdiff as long

getmonthdiff=datediff("m",dt1,dt2)

msgbox getmonthdiff

thx..

Edited 5 Years Ago by blocker: n/a

This question has already been answered. Start a new discussion instead.