<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dates between 2 given dates in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371286#M182763</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please check this sample program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

data: begin_date type sy-datum value '20060110',
      end_date type sy-datum value '20060125'.

data: idatum type table of sy-datum with header line.

idatum = begin_date.
append idatum.

do.
  if idatum  = end_date.
    exit.
  endif.
  idatum =  idatum + 1.
  append idatum.
enddo.


loop at idatum.

  write:/ idatum.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 May 2006 15:46:34 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2006-05-24T15:46:34Z</dc:date>
    <item>
      <title>Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371285#M182762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt; i want to know is there any function module which will return all the dates between the given range of dates.&lt;/P&gt;&lt;P&gt;example : if i give 20/01/2006 and 25/01/2006 it should return 20/01/2006,21/01/2006,22/01/2006,23/01/2006,24/01/2006,25/01/2006.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Srikanth Kidambi.&lt;/P&gt;&lt;P&gt;Intelligroup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 15:40:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371285#M182762</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-24T15:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371286#M182763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please check this sample program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

data: begin_date type sy-datum value '20060110',
      end_date type sy-datum value '20060125'.

data: idatum type table of sy-datum with header line.

idatum = begin_date.
append idatum.

do.
  if idatum  = end_date.
    exit.
  endif.
  idatum =  idatum + 1.
  append idatum.
enddo.


loop at idatum.

  write:/ idatum.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 15:46:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371286#M182763</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-05-24T15:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371287#M182764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not aware of any function that gives the dates as such, but there is one that gives the days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In you case probably you can write a custom function and inside the increment the starting date by till you reach the end date and return all the dates in a internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;P&gt;Note : Please mark the helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 15:48:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371287#M182764</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-24T15:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371288#M182765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  logic provided by Rich is really good one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABAP automatically calculates the next date.&lt;/P&gt;&lt;P&gt;Do need to worry if the data type is DATS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Core data type for date is DATS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 15:50:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371288#M182765</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-24T15:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371289#M182766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srikanth,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can use FM 'MONTHS_BETWEEN_TWO_DATES' and then increment month to get required value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vicky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 15:50:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371289#M182766</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-24T15:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371290#M182767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Srikanth,&lt;/P&gt;&lt;P&gt;  Check these FM &amp;lt;b&amp;gt;RS_VARI_V_DAYS_UP_TO_NOW&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 15:51:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371290#M182767</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-24T15:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371291#M182768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srikanth,&lt;/P&gt;&lt;P&gt;check the below logic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Logic is :&lt;/P&gt;&lt;P&gt;Calculate in a loop using +1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="-------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT abc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : BEGIN OF itab OCCURS 0,&lt;/P&gt;&lt;P&gt;mydate TYPE sy-datum,&lt;/P&gt;&lt;P&gt;END OF itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT-OPTIONS budat FOR sy-datum OBLIGATORY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="-----------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END-OF-SELECTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM get_all_dates.&lt;/P&gt;&lt;P&gt;LOOP AT itab.&lt;/P&gt;&lt;P&gt;WRITE / itab-mydate.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM get_all_dates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR itab.&lt;/P&gt;&lt;P&gt;REFRESH itab.&lt;/P&gt;&lt;P&gt;DATA : myctr TYPE i.&lt;/P&gt;&lt;P&gt;DATA : newdate TYPE sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newdate = budat-low.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt; Loop And Generate Dates&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;IF newdate &amp;lt;= budat-high.&lt;/P&gt;&lt;P&gt;itab-mydate = newdate.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;itab-mydate = sy-datum.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newdate = newdate + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM. "get_all_dates&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 15:53:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371291#M182768</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-24T15:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371292#M182769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srikanth,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am sorry, I misunderstood your question as months between two dates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rich's code is excellent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vicky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 15:57:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371292#M182769</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-24T15:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371293#M182770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Rich,&lt;/P&gt;&lt;P&gt; the logic is excellent.but one problem with that logic is it wont exclude the country specific holidays. &lt;/P&gt;&lt;P&gt;Mean while i too tried to find out the function module and i succeeded in getting it.&lt;/P&gt;&lt;P&gt;here it is, "RKE_SELECT_FACTDAYS_FOR_PERIOD". this also gives all the given dates between 2 given dates excluding the country specific holidays(it is having the FactoryID field)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any how,Thanks for giving good logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;srikanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 16:21:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371293#M182770</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-24T16:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371294#M182771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh,  If you had mentioned that you want only working days,  then I would have went a slightly different way.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

data: begin_date type sy-datum value '20060110',
      end_date type sy-datum value '20060125'.

data: idatum type table of sy-datum with header line.
data: indicator type scal-indicator.

idatum = begin_date.
append idatum.

do.
  if idatum  = end_date.
    exit.
  endif.



  idatum =  idatum + 1.


  call function 'DATE_CONVERT_TO_FACTORYDATE'
       exporting
            date                 = idatum
            factory_calendar_id  = 'P6'
       importing
            workingday_indicator = indicator
       exceptions
            others               = 7.

  if indicator = space.
    append idatum.
  endif.

enddo.

loop at idatum.
  write:/ idatum.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2006 17:03:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371294#M182771</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-05-24T17:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between 2 given dates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371295#M182772</link>
      <description>&lt;P&gt;Is there any standard FM to generate dates if i want monthly or weekly or yearly &lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 12:13:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dates-between-2-given-dates/m-p/1371295#M182772</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-11-17T12:13:52Z</dc:date>
    </item>
  </channel>
</rss>

