<?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: Comparing dates in select query. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787628#M911230</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Eswar . it's working.. Can u tell me how i can write "" for all entries in &amp;lt;itab&amp;gt;""" in the same. I&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Shridhar Patil on May 7, 2008 8:46 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 May 2008 06:45:58 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-07T06:45:58Z</dc:date>
    <item>
      <title>Comparing dates in select query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787624#M911226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to select data from one table such that the date field of the table should be either today's date or earlier date.&lt;/P&gt;&lt;P&gt;       How can I write such comparison statement in select query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2008 06:24:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787624#M911226</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-07T06:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates in select query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787625#M911227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;&lt;SPAN __default_attr="sylfaen" __jive_macro_name="font"&gt;&lt;SPAN __default_attr="15" __jive_macro_name="size"&gt;
Try with a query similar as below:
&lt;PRE&gt;&lt;CODE&gt;SELECT &amp;lt;fld1&amp;gt; &amp;lt;fld2&amp;gt; ...
  INTO TABLE &amp;lt;itab&amp;gt;
  FROM &amp;lt;TAB&amp;gt;
  WHERE &amp;lt;date&amp;gt; &amp;lt;= sy-datum
  ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN __default_attr="maroon" __jive_macro_name="color"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2008 06:27:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787625#M911227</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-07T06:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates in select query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787626#M911228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;select * from ur_table into i_table
where date_frm_table LE sy-datum&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if any doubts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Vibha &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please mark all the helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2008 06:28:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787626#M911228</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-07T06:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates in select query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787627#M911229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;today_date = sy-datum.&lt;/P&gt;&lt;P&gt;yesterday-date = sy-datum - 1.&lt;/P&gt;&lt;P&gt;select * from table &lt;/P&gt;&lt;P&gt;       into table i_tab&lt;/P&gt;&lt;P&gt; where date = today_date&lt;/P&gt;&lt;P&gt; or date = yesterday_date.&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;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2008 06:28:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787627#M911229</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-07T06:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates in select query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787628#M911230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Eswar . it's working.. Can u tell me how i can write "" for all entries in &amp;lt;itab&amp;gt;""" in the same. I&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Shridhar Patil on May 7, 2008 8:46 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2008 06:45:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787628#M911230</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-07T06:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates in select query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787629#M911231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;&lt;SPAN __default_attr="sylfaen" __jive_macro_name="font"&gt;&lt;SPAN __default_attr="15" __jive_macro_name="size"&gt;
Something like below???
&lt;PRE&gt;&lt;CODE&gt;SELECT &amp;lt;fld1&amp;gt; &amp;lt;fld2&amp;gt; ...
  INTO TABLE &amp;lt;itab&amp;gt;
  FROM &amp;lt;TAB&amp;gt;
  FOR ALL ENTRIES OF &amp;lt;itab1&amp;gt;
  WHERE &amp;lt;fld1&amp;gt; = &amp;lt;itab1&amp;gt;-fld1
  AND   &amp;lt;date&amp;gt; &amp;lt;= sy-datum
  ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN __default_attr="maroon" __jive_macro_name="color"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2008 06:49:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787629#M911231</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-07T06:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates in select query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787630#M911232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi   &lt;STRONG&gt;Sridhar&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"For all entries" key word is used to interact with the more than one internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example program:&lt;/P&gt;&lt;P&gt;My requirement is to get the sales order numbers from given range of dates. For each sales order number&lt;/P&gt;&lt;P&gt;i need to get the available item numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-options: s_date for sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data: it_vbak type table of vbak with header line.(sales order header data),&lt;/P&gt;&lt;P&gt;it_vbap type table of vbap with header line.(sales order item infomration).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;getting the sales order header data with in given range of dates&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbak&lt;/P&gt;&lt;P&gt;into table it_vbak&lt;/P&gt;&lt;P&gt;where erdat in s_date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;getting the item data for each record in it_vbak using the "for all entries"&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not it_vbak[] is initial.&lt;/P&gt;&lt;P&gt;Select * from vbap&lt;/P&gt;&lt;P&gt;into table it_vbap&lt;/P&gt;&lt;P&gt;for all entries in it_vbak&lt;/P&gt;&lt;P&gt;where vbeln = it_vbak-vbeln.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when using for all entries we need to remember some condiitons:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) We must check if the first internal table is empty or not. If we are we are not checking this&lt;/P&gt;&lt;P&gt;conditons: "If not it_vbak[] is initial".If first internal table is empty it extract all the data from the&lt;/P&gt;&lt;P&gt;database. It is very dangerous.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) U make sure to poulate all the key fields in first internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is helpful rewards points&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;Eshwar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2008 06:49:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787630#M911232</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-07T06:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates in select query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787631#M911233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Gurus....Problem is solved.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2008 07:39:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-dates-in-select-query/m-p/3787631#M911233</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-07T07:39:32Z</dc:date>
    </item>
  </channel>
</rss>

