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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.