Count How many months between 2 dates?

aronnov

Active Member
Is there any business function or easy way to count the number of months in between two dates. Say October 1st 2001 - April 1st 2004? Any feedback will be appreciated. Thanks.
 
I have found that data source DN0700003 seems to be what I want. Does anyone know how I would go about using this certain business function. meaning what 2 records do I use to send over the dates?
 
aronnov

The simple calculation is: (Year_2 - Year_1) * 12 + Month_2 - Month_1
You could use one of the following ER lines:

Months = months_between(Date_1, Date_2)

Months = (date_year(Date_2) - date_year(Date_1)) * 12 + date_month(Date_2) - date_month(Date_1)
 
Peter,

Thanks for the reply. I have one more question however and hope you may, or anyone else for that matter may have an answer. Is there anyway inside of Report Design inside of JDE to assign a variable with a static date value. For instance, How would I go about assigning 'Variable Date' with the value of 05/01/2002 and it recognize that as a date instead of text? Thanks.
 
Put it in a processing option - would be the most flexible solution.
That way you could change the date - without having to edit the code.

(db)

--
 
Hi aronnov,

Using B0800013 Convert String To Date, you can assign constant value to a date variable.

The BSFN accept a 10 char length string (alias VC10A) as input in "MM/DD/YYYY" format. Define a string variable based on VC10A, assign the constant date as text to it (e.g. "05/19/2004") and use the BSFN to convert it to your date variable.

Hope, this helps a bit.

Regards,

Zoltán
 
Zoltán,

In what format should the string be in? Should I pass it in as 05192004? Thanks.

Aaron
 
Hi Aaron,

You shouldn't pass as 05192004.
You should pass as:

2 digit month, 2 digit day and 4 digit year separated by slash.

For example: 03/15/2004 for 15th March 2004.

Regards,

Zoltán
 
Back
Top