‎2006 Aug 29 10:44 AM
HI FRIENDS,
ACTUALLY IN MY SELECT-OPTIONS I HAVE USED DATE BETWEEN 03/06/1980 TO 04/12/1980
BASED ON THIS DATE I HAVE TO CALCULATE NUMBER OF MONTHS.
WILL THIS BE DONE AUTOMATICALLY OR I NEED TO WRITE ANY CODE FOR CONVERTING THE DATE RANGE INTO NUMBER OF MONTHS.
REGARDS
SIRI.
‎2006 Aug 29 10:47 AM
You can use the function module 'MONTHS_BETWEEN_TWO_DATES' in your program .
~Suresh
‎2006 Aug 29 10:46 AM
Hi,
Use FM's : MONTHS_BETWEEN_TWO_DATES_NEW
MONTHS_BETWEEN_TWO_DATES
FIMA_DAYS_AND_MONTHS_AND_YEARS
Sample code :
DATA : x_no_months type i.
DATA : x_stdat like sy-datum,
x_enddat like sy-datum.
x_stdat = s_date-low
x_enddat = s_date-high
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = x_stdat
i_datum_von = x_enddat
IMPORTING
e_monate = x_no_months.
x_no_months will contain no.of months.Regards
Appana
‎2006 Aug 29 11:11 AM
tHANX APPANA,
AFTER CONVERTING THAT DATES INTO MONTHS I SHOUILD VALIDATE THAT MONTHS SO AS THAT SHOULD BE ONLY BETWEEN 1 AND 12 ONLY .
CAN U PLZ HELP ME.
REGARDS,
SIRI.
‎2006 Aug 29 11:18 AM
Hi,
Check this code :
IF x_months BETWEEN 1 AND 12.
write ' with in the range'.
ELSE.
write ' out of range'.
ENDIF.
Regards
Appana
‎2006 Aug 29 11:27 AM
Hello Sireesha.
It depends on your requirement actually it is not needed but if you have the requirement that the dates have to be within a year ...in that case you need to validate it to be between 1 to 12..otherwise not needed.
pls note that the answer of the FM would be 0 if you the date range is within the same month...i.e. 29.08.2006 and 01.08.2006 would return the answer as ZERO.
Rgds
Anurag
Message was edited by: Anurag Bankley
‎2006 Aug 29 11:53 AM
yes ANURAG MY REQUIREMENT IS L TO VALIDATE THE MONTHS SO THEY SHOULD BE ONLY BETWEEN 1 AND 12 .
BECAUSE COUNTING IS FOR ONE YEAR AND COUNTED EVERY MONTH
SO THE DATES I GIVE WILL NOT IN ONE MONTH E.
THANKX.
SIRI.
‎2006 Aug 29 10:47 AM
You can use the function module 'MONTHS_BETWEEN_TWO_DATES' in your program .
~Suresh
‎2006 Aug 29 10:47 AM
‎2006 Aug 29 10:54 AM
Hi
you can check this FM
HR_ECM_GET_NUMBER_OF_MONTHS
It gives the number of months between 2 dates
best regards,
Thangesh
‎2006 Aug 29 10:56 AM
you can use the below logic.
at selection-screen.
call function 'MONTHS_BETWEEN_TWO_DATES_NEW'
exporting
i_datum_bis = s_date-high
i_datum_von = s_date-low
i_kz_incl_bis = SPACE
i_kz_volle_monate = 'X'
importing
e_monate = lmonths.
Regards
Anurag
‎2006 Aug 29 12:43 PM
Hi Sireesha,
You can also use following method.
CL_RECA_DATE->MONTHS_BETWEEN_TWO_DATES.
Inputs to this method are:
ID_DATE_TO type sy-datum required
ID_DATE_FROM type sy-datum required
output is:
RD_MONTHS : No. of months between entered dates.
Hope this helps.
Regards.
vishwas.