Hello Sudheer
If you have class <b>CL_RECA_DATE</b> available in your system you can call its static method <b>GET_DATE_DIFF</b>.
Regards
Uwe
Hi,
PLEASE CHECK OUT THE BELOW PROGRAM IT MIGHT HELP YOU
REPORT ZDATEDIFF.
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
WRITE:/ 'Difference in Days ', EDAYS.
WRITE:/ 'Difference in Months ', EMONTHS.
WRITE:/ 'Difference in Years ', EYEARS.
INITIALIZATION.
FROMDATE = SY-DATUM - 60.
also check out the below program to fine date difference
data: d1 like sy-datum,
d2 like sy-datum.
data: diff type i.
d1 = '20060331'.
d2 = '20060220'.
diff = d1 - d2.
write : / diff .
Also chek these FMs:
'CSCP_PARA1_GET_PERIODS'
HR_99S_INTERVAL_BETWEEN_DATES(Months, Years and days)
COMPUTE_YEARS_BETWEEN_DATES
EHS_CALC_YEARS_BETWEEN_DATES
DAYS_BETWEEN_TWO_DATES
MONTHS_BETWEEN_TWO_DATES
For No of week days between two dates please check out the below program it might help you
report zrich_0003.
data: begin of itab occurs 0,
datum type sy-datum,
end of itab.
data: weekday like dtresr-weekday.
data: number_lines type i.
parameters: p_sdatum type sy-datum,
p_edatum type sy-datum.
itab-datum = p_sdatum.
append itab.
do.
if itab-datum = p_edatum.
exit.
endif.
itab-datum = itab-datum + 1.
call function 'DATE_TO_DAY'
exporting
date = itab-datum
importing
weekday = weekday.
if weekday = 'Sat.'
or weekday = 'Sunday'.
continue.
endif.
append itab.
enddo.
describe table itab lines number_lines.
write:/ 'Number of days between dates is', number_lines.
-
for comparisoin between two dates please check out the link below it will help you
http://help.sap.com/saphelp_webas620/helpdata/en/fc/eb3509358411d1829f0000e829fbfe/frameset.htm
**********please reward points if the information is helpful to you*************
Hi,
look into the therad
https://forums.sdn.sap.com/click.jspa?searchID=3361043&messageID=2373018
You can use <b>FIMA_DAYS_AND_MONTHS_AND_YEARS</b>
See the below code for ur refrence:
REPORT ZDATEDIFF.
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
WRITE:/ 'Difference in Days ', EDAYS.
WRITE:/ 'Difference in Months ', EMONTHS.
WRITE:/ 'Difference in Years ', EYEARS.
INITIALIZATION.
FROMDATE = SY-DATUM
<b>Reward points if useful</b>
Regards
Ashu
" Here is the program link
http://www.sap-img.com/fu004.htm>
reward points if it is usefull ...
Girish
Just check this this code will give you the exact years,months and days between two dates...please reward if usefull
DATA : wk_date1 LIKE sy-datum VALUE '20070717', "End date
wk_date2 LIKE sy-datum VALUE '19951201', "Start date
wk_day1(2) TYPE c,
wk_day2(2) TYPE c,
wk_day3(2) TYPE c,
wk_month1(2) TYPE c,
wk_month2(2) TYPE c,
wk_month3(2) TYPE c,
wk_year1(4) TYPE c,
wk_year2(4) TYPE c,
wk_year3(4) TYPE c.
wk_year1 = wk_date1(4).
wk_year2 = wk_date2(4).
wk_month1 = wk_date1+4(2).
wk_month2 = wk_date2+4(2).
wk_day1 = wk_date1+6(2).
wk_day2 = wk_date2+6(2).
wk_day3 = wk_day1 - wk_day2.
wk_month3 = wk_month1 - wk_month2.
wk_year3 = wk_year1 - wk_year2.
*****Month and year calculation
IF wk_month3 < 0.
wk_year3 = wk_year3 - 1.
wk_month3 = 12 + wk_month3.
ELSEIF wk_month3 = 0 AND wk_day3 < 0.
wk_year3 = wk_year3 - 1.
ENDIF.
********Day calculation.
if wk_day3 < 0.
data: last_month_last_day type sy-datum.
last_month_last_day = wk_date1.
last_month_last_day+6(2) = '01'.
last_month_last_day = last_month_last_day - 1.
clear wk_day1.
wk_day1 = last_month_last_day+6(2).
wk_day3 = wk_day3 + wk_day1.
endif.
WRITE : 'Days : ', wk_day3,
/ 'Months : ', wk_month3,
/ 'Years : ', wk_year3.
Add a comment