Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

All the months between given dates

Former Member
0 Likes
1,014

Hi Feriends,

Is there any function module that returns all the months between the given dates.

i.e. if i give 03/2007 in low and 06/2007 in high it should give the 3rd 4th and 5th months.

Please let me know if any ofu have faced the same requirement.......

Thanks,

Chaitanya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
940

Use the below code:

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.

Thanks

Hi Feriends,

Is there any function module that returns all the months between the given dates.

i.e. if i give 03/2007 in low and 06/2007 in high it should give the 3rd 4th and 5th months.

Please let me know if any ofu have faced the same requirement.......

Thanks,

Chaitanya

4 REPLIES 4
Read only

Former Member
0 Likes
941

Use the below code:

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.

Thanks

Read only

Former Member
0 Likes
940

SELECT-OPTIONS : S_SPMON FOR PGPL-SPMON.

DATA : TOMON(2) TYPE N,

FROMMON(2) TYPE N.

DATA : ITAB LIKE T247 OCCURS 0 WITH HEADER LINE.

FROMMON = S_SPMON-LOW+4(2).

TOMON = S_SPMON-HIGH+4(2).

SELECT * FROM T247 INTO TABLE ITAB WHERE MN BETWEEN FROMMON AND TOMON.

LOOP AT ITAB.

WRITE : / ITAB-KTX,ITAB-LTX.

ENDLOOP.

OR YOU CAN USE FM MONTH_NAMES_GET INSTEAD OF SELECTING DATA FROM T247.

REGARDS

SHIBA DUTTA

Read only

RaymondGiuseppi
Active Contributor
0 Likes
940

Look at FM CSCP_PARA1_GET_PERIODS.

From a couple of dates, give you a table of beginning of period,

Regards

Read only

anversha_s
Active Contributor
0 Likes
940

hi,

Check these fm.

MONTHS_BETWEEN_TWO_DATES

MONTHS_BETWEEN_TWO_DATES_NEW

HR_99S_MONTHS_BETWEEN_DATES

HR_MONTHS_BETWEEN_TWO_DATES

Rgds

Anver