‎2008 Apr 16 3:32 PM
Hello ,
I want to check condition on the basis of difference between two dates .
One date is current date .
Second date - From table
Please help me with Fm which will give difference between two dates in Months .
Thanks and Regards ,
Rahul
‎2008 Apr 16 3:44 PM
Hi,
Use the below logic.
data: v_days type i,
v_months type i,
v_years type i,
v_all_days type i.
CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'
EXPORTING
BEG_DA = '20080101'
END_DA = '20080416'
IMPORTING
NO_DAY = v_days
NO_MONTH = v_months
NO_YEAR = v_years
NO_CAL_DAY = v_all_days.
write:/ 'Days = ', v_days.
write:/ 'Months = ', v_months.
write:/ 'Years = ', v_years.
write:/ 'All days = ', v_all_days.
‎2008 Apr 16 3:34 PM
Hi,
Please use FMs below:
DAYS_BETWEEN_TWO_DATES "Gives difference in days
MONTHS_BETWEEN_TWO_DATES " Gives difference in months
Thanks,
Sriram Ponna.
‎2008 Apr 16 3:35 PM
Use :FM HR_HK_DIFF_BT_2_DATES
pass 04 for parameter OUTPUT_FORMAT
‎2008 Apr 16 3:37 PM
Hello
You may want to try FM DAYS_BETWEEN_TWO_DATES or use se37 to find other FMs that do date calculations.
Regards
Greg Kern
‎2008 Apr 16 3:44 PM
Hi,
Use the below logic.
data: v_days type i,
v_months type i,
v_years type i,
v_all_days type i.
CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'
EXPORTING
BEG_DA = '20080101'
END_DA = '20080416'
IMPORTING
NO_DAY = v_days
NO_MONTH = v_months
NO_YEAR = v_years
NO_CAL_DAY = v_all_days.
write:/ 'Days = ', v_days.
write:/ 'Months = ', v_months.
write:/ 'Years = ', v_years.
write:/ 'All days = ', v_all_days.
‎2008 Apr 16 3:54 PM
Hello ,
Thanks for the response .
Have a nice day ahead .
Thanks and regards ,
RRAI
‎2008 Apr 16 3:50 PM
Hi,
You can use the below function modules.
HR_ECM_GET_NUMBER_OF_MONTHS
HR_GBSXP_GET_MONTHS
HR_IN_CALC_MONTHS
‎2008 Apr 16 3:56 PM
Hi,
Check the below code.
data: v_months type i.
CALL FUNCTION 'HR_GBSXP_GET_MONTHS'
EXPORTING
FIRST_DATE = '20080101'
SECOND_DATE = '20080416'
MODIFY_INTERVAL = 'M'
IMPORTING
DURATION = v_months
EXCEPTIONS
INVALID_SEQ_DATES = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write:/ v_months.