Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count months between two different years.

Status
Not open for further replies.

Shout

Programmer
Feb 4, 2003
3
NO
Hi, how do I get the correct number of months when calculating months between a "yrmo"-field. Eksample:
200510 and 200410.

Thanks.
 
Hi
I think you need DateDiff. The example above would, perhaps, look like this:
Code:
strDate1 = "200410"
strDate2 = "200510"
dte1 = DateSerial(Left(strDate1, 4), Mid(strDate1, 5, 2), 1)
dte2 = DateSerial(Left(strDate2, 4), Mid(strDate2, 5, 2), 1)

intDiff = DateDiff("m", dte1, dte2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top