<?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: Date Difference in SQL Where Condition? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-difference-in-sql-where-condition/m-p/2848699#M667420</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Anji,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply. Actually i want this logic in SQL statement, later i figure it out that this logic is not possible in sql where statement because this is incorrect statement. &lt;/P&gt;&lt;P&gt;Consider this:&lt;/P&gt;&lt;P&gt;field1 = 4&lt;/P&gt;&lt;P&gt;field2 = 2&lt;/P&gt;&lt;P&gt;WHERE field1 - field2 = 2&lt;/P&gt;&lt;P&gt;compiler interprets it as &lt;/P&gt;&lt;P&gt;WHERE 2 = 2 " this is illogical condition thats why its not possible &lt;/P&gt;&lt;P&gt;However i really appreciate your reply. Once again thank you and points for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ahsan Majeed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Sep 2007 04:55:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-24T04:55:40Z</dc:date>
    <item>
      <title>Date Difference in SQL Where Condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-difference-in-sql-where-condition/m-p/2848697#M667418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem while fetching records from two tables LIPS and VAPMA on basis of date difference. My SQL conditions/statements are as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA myvar type p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. SELECT SUM( lips~lfimg )&lt;/P&gt;&lt;P&gt;    FROM lips INNER JOIN vapma ON lips&lt;SUB&gt;vgbel = vapma&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;    AND vapma&lt;SUB&gt;matnr = lips&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;    INTO myvar&lt;/P&gt;&lt;P&gt;    WHERE DATEDIFF(lips&lt;SUB&gt;erdat , vapma&lt;/SUB&gt;audat) = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. SELECT SUM( lips~lfimg )&lt;/P&gt;&lt;P&gt;    FROM lips INNER JOIN vapma ON lips&lt;SUB&gt;vgbel = vapma&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;    AND vapma&lt;SUB&gt;matnr = lips&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;    INTO mywar&lt;/P&gt;&lt;P&gt;    WHERE &lt;/P&gt;&lt;P&gt;    lips&lt;SUB&gt;erdat - vapma&lt;/SUB&gt;audat = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Above SQL statements are not working, kindly help me out. Thanking you in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ahsan Majeed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Sep 2007 12:13:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-difference-in-sql-where-condition/m-p/2848697#M667418</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-23T12:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Date Difference in SQL Where Condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-difference-in-sql-where-condition/m-p/2848698#M667419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Do like this:&lt;/P&gt;&lt;P&gt;data: begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;           vbeln like lips-vbeln,&lt;/P&gt;&lt;P&gt;           posnr like lips-posnr,&lt;/P&gt;&lt;P&gt;           erdat like sy-datum,&lt;/P&gt;&lt;P&gt;           lfimg like lips-lfimg,&lt;/P&gt;&lt;P&gt;           audat like sy-datum,&lt;/P&gt;&lt;P&gt;           d_diff type i,&lt;/P&gt;&lt;P&gt;     end of itab.&lt;/P&gt;&lt;P&gt;data : v_qty like lips-lfimg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a&lt;SUB&gt;vbeln a&lt;/SUB&gt;posnr  a&lt;SUB&gt;erdat a&lt;/SUB&gt;lfimg b~audat  into table itab&lt;/P&gt;&lt;P&gt;FROM lips as a INNER JOIN vapma as b &lt;/P&gt;&lt;P&gt;ON a&lt;SUB&gt;vgbel = b&lt;/SUB&gt;vbeln.&lt;/P&gt;&lt;P&gt;clear v_qty.&lt;/P&gt;&lt;P&gt;sort itab by vbeln posnr.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;   itab-d_diff = itab-erdat - itab-audat.&lt;/P&gt;&lt;P&gt;  if itab-d_diff = 2.&lt;/P&gt;&lt;P&gt;     v_qty = v_qty + itab-lfimg.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if useful&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Sep 2007 13:53:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-difference-in-sql-where-condition/m-p/2848698#M667419</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-23T13:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Date Difference in SQL Where Condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-difference-in-sql-where-condition/m-p/2848699#M667420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Anji,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply. Actually i want this logic in SQL statement, later i figure it out that this logic is not possible in sql where statement because this is incorrect statement. &lt;/P&gt;&lt;P&gt;Consider this:&lt;/P&gt;&lt;P&gt;field1 = 4&lt;/P&gt;&lt;P&gt;field2 = 2&lt;/P&gt;&lt;P&gt;WHERE field1 - field2 = 2&lt;/P&gt;&lt;P&gt;compiler interprets it as &lt;/P&gt;&lt;P&gt;WHERE 2 = 2 " this is illogical condition thats why its not possible &lt;/P&gt;&lt;P&gt;However i really appreciate your reply. Once again thank you and points for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ahsan Majeed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2007 04:55:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-difference-in-sql-where-condition/m-p/2848699#M667420</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-24T04:55:40Z</dc:date>
    </item>
  </channel>
</rss>

