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

Dates between 2 dates - FM

Former Member
0 Likes
2,243

Guys,

Can somebody please let me know the FM, that will give me the dates between 2 dates?

Thanks in advance....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,191

Hi

You don't need any fm (and I don't know if there's any one):

DATA: DAY_1 TYPE SY-DATUM   VALUE '20081020',
           DAY_2 TYPE SY-DATUM   VALUE '20081231'.

DATA: DAY TYPE SY-DATUM.


DO.
  DAY = DAY_1 + 1.
  IF DAY = DAY_2.
     EXIT.
  ENDIF.
  WRITE / DAY.
ENDDO.

Max

13 REPLIES 13
Read only

Former Member
0 Likes
2,192

Hi

You don't need any fm (and I don't know if there's any one):

DATA: DAY_1 TYPE SY-DATUM   VALUE '20081020',
           DAY_2 TYPE SY-DATUM   VALUE '20081231'.

DATA: DAY TYPE SY-DATUM.


DO.
  DAY = DAY_1 + 1.
  IF DAY = DAY_2.
     EXIT.
  ENDIF.
  WRITE / DAY.
ENDDO.

Max

Read only

Former Member
0 Likes
2,191

Have you tried searching yourself?

Rob

Read only

0 Likes
2,191

This might be the 10th time I am seeing this question in the last couple of weeks.

Read only

0 Likes
2,191

Rob,

I did try, and then only I posted it on the forum. I found those are not relevent to me.

MxG,

I have not found it when I searched it.

I would have appriciated had you answered it.

Read only

0 Likes
2,191

Hi Sam,

Check out the Function Module


RKE_SELECT_FACTDAYS_FOR_PERIOD 

Or 

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.

Thanks,

Chidanand

Read only

0 Likes
2,191

So, didn't Max's solution help?

Rob

Read only

0 Likes
2,191

Hi,

Sorry to enter into discussion in the middle.

I tried to execute max's code but it took me to DUmp and its serious error my system adminstartor has given worng regarding this program. He said highly memory consuming code and may damage kernal . i think its so strange.

When i tried to find where the error occurs its in the write statement

write:/ day.

Program is requesting for 740232384 bytes.

Regards

Balu

Read only

0 Likes
2,191

Not really a serious error - I don't see how it could damage the kernel. But yes, it's in an infinite loop.

Rob

Read only

0 Likes
2,191

you should have seen Do .. enddoo w/o any exit point.

Read only

0 Likes
2,191

we can correct the code.

DATA: DAY_1 TYPE SY-DATUM   VALUE '20081020',
           DAY_2 TYPE SY-DATUM   VALUE '20081231'.

DO.

  IF DAY_1 = DAY_2.
     EXIT.
  ENDIF.
  WRITE / DAY_1.
  DAY_1 = DAY_1 + 1.
ENDDO.

Read only

BH2408
Active Contributor
0 Likes
2,191

Hi ,

this is FM for the finding the diff b/w 2 dats.

FIMA_DAYS_BETWEEN_TWO_DATES.

Regards,

Bharani

Read only

uwe_schieferstein
Active Contributor
0 Likes
2,191

Hello Sam

Class CL_RECA_DATE provides many useful methods, e.g.:

GET_DATE_DIFF
GET_DAYS_BETWEEN_TWO_DATES

Another interesting classes is CL_RECA_DATE_SLICES.

Regards

Uwe

Read only

0 Likes
2,191

Sorry for responding late, Max's code worked for me. Actually it was simple but did not strike to me before. I had to make minor changes.

Thanks all.