Skip to Content
author's profile photo Former Member
Former Member

How to get all the dates in between a range of dates

I want to store all the dates that come in the date range given by user as input. eg:

Date-low = '01-01-2005'

Date-high = '05-01-2005'

Then itab should contain








Is there any FM which gives a list of dates that comes between 2 dates ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2005 at 06:42 AM

    Hi Shankara Narayanan T.V

    I tried the code of : loop at s_inputdate.

    1. first error : cannot be more than 8 char long.

    2. secondly its showing only one entry -ie. the low one.

    It loops only one time.

    Thanks & Regards,

    Amit Mittal.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello Shankar,

      Was your previous probelm solved? If yes, then please reward the points to the answers that you have found to be useful.

      Now coming to your question, I think it should actually be started in a new thread. Anyways, here' what I think :

      tables mara.
      select-options: s_matnr for mara-matnr.
      data: begin of material occurs 0,
              matnr type matnr,
            end of material.
        select matnr 
          from mara
          into table material
         where matnr in s_matnr.

      The reasons why I have given the above code :

      1. I believe even if there were to be some way of coding and extracting the materials in the given range, it is definitely going to take some time (compared to the time it has taken to code the above SELECT , atlease 😊) to realize the logic.

      2. And even if the logic were to be written, it would definitely take more time to execute the logic than to obtain the materials from the database.

      3. Let us say that the user has given a range like A00000000000000000 to A00000000000000999. This is actually the set of all the 1000 materials. Even if you write the logic to get all these 1000 materials, most of the materials might not even exist in your system. Imagine the number of unwanted MATNRs that will get generated for some other range, which can probably take forever to generate the values of MATNRs.

      Hope that was convincing enough...


      Anand Mandalika.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2005 at 11:31 AM

    Hi Dear Shankara Narayanan T.V

    1. I have created a sample program for your requirement,

    and also tested it. Its working fine.

    2. Logic is :

    Calculate in a loop using +1.

    2. I m new to this sdn.

    Please give points if you are satisfied.

    Thanks & Regards,

    Amit Mittal.


    REPORT abc.


    DATA : BEGIN OF itab OCCURS 0,

    mydate TYPE sy-datum,

    END OF itab.




    PERFORM get_all_dates.

    LOOP AT itab.

    WRITE / itab-mydate.



    FORM get_all_dates.

    CLEAR itab.

    REFRESH itab.

    DATA : myctr TYPE i.

    DATA : newdate TYPE sy-datum.

    newdate = budat-low.


    Loop And Generate Dates


    IF newdate <= budat-high.

    itab-mydate = newdate.

    APPEND itab.


    itab-mydate = sy-datum.



    newdate = newdate + 1.


    ENDFORM. "get_all_dates

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.