deturmining number of months between 2 dates (1 Viewer)

norm

Registered User.
Local time
Today, 00:49
Joined
Sep 20, 2000
Messages
62
I'm trying to display the number of months contained within a report grouping. I have a typical date field to work with where dates can range over years.

Is there an easy function for this that has eluded me?? Or/Also, is there a way to use user defined functions in text boxes?? I have a function all written to do the above but can't seem to use it in the text box!

Any help would be greatly appreciated.

rock on,
norm
 

pdx_man

Just trying to help
Local time
Yesterday, 21:49
Joined
Jan 23, 2001
Messages
1,347
For the difference in Months, look at Datediff("m",Date1,Date2)

For your own function in a text box, =FuntionName(Parameter1, Parameter2, ...)
 

norm

Registered User.
Local time
Today, 00:49
Joined
Sep 20, 2000
Messages
62
dude, ROCK ON! Can't believe i didn't find datediff!! ...and for some reason my function WORKS NOW?????? It wouldn't work yesterday for the life of me.

This is what I ended up doing yesterday:
=IIf(DatePart("yyyy",Max([PERIOD_NAME]))=DatePart("yyyy",Min([PERIOD_NAME])),DatePart("m",Max([PERIOD_NAME]))-DatePart("m",Min([PERIOD_NAME]))+1,((DatePart("yyyy",Max([PERIOD_NAME] ))-DatePart("yyyy",Min([PERIOD_NAME]))-1)*12)+(DatePart("m",Max([PERIOD_NAME]))+(12-DatePart("m",Min([PERIOD_NAME]))+1)))

Now with your help:
=DateDiff("m",Min([PERIOD_NAME]),Max([PERIOD_NAME]))+1


Or with my function:
=NumberMonths(Min([PERIOD_NAME]),Max([PERIOD_NAME]))


In any case, thanks again,
norm
 

Users who are viewing this thread

Top Bottom