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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting the number of months 1

Status
Not open for further replies.

xanra

IS-IT--Management
Jan 16, 2007
20
US
Is there a way to display the number of months between two dates.

For example if the first date is 02/01/07 and the second date is 03/01/07 i want to display 13 instead of 1.

which is done by the month({date2}) - month({date1})

Thanks in advance.
-Paul
 
oops, sorry.. the second date is supposed to be 03/01/2008.
 
I think you need quotes around m:

DateDiff("m", {date1}, {date2})

Andy
 
Andy thank you very much! Exactly what i needed.
 
Note that datediff() will return a 1 month difference for:

datediff("m",date(2007,2,28),date(2007,3,1))

...even though there is only one day difference, since datediff just subtracts the months, regardless of the days. While that might work in your case, you should be aware of this. For more precision, you could use "d" and divide by 30.4375, which will be more accurate on average.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top