<?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: SQL Command-Date time in where clause in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588924#M1567020</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But don't proceed like that, as it shifts the where selection to within the loop, and will &lt;EM&gt;hammer&lt;/EM&gt; performance (on any suitable large table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd still like the original poster specify what his problem is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 23 Jan 2011 17:29:15 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2011-01-23T17:29:15Z</dc:date>
    <item>
      <title>SQL Command-Date time in where clause</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588921#M1567017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends&lt;/P&gt;&lt;P&gt;  complecated SQL command for fetching records using where clause of Date and Time - (if using Select option).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very Helpfull.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types: begin of ty_vbak,
        vbeln type vbak-vbeln,
        erdat type vbak-erdat,
        erzet type vbak-erzet,
       end of ty_vbak.
data: lt_vbak type table of ty_vbak.
field-symbols: &amp;lt;fs_vbak&amp;gt; type ty_vbak.

select vbeln erdat erzet into table lt_vbak
from vbak
where ( ( erdat = '20081123' and erzet &amp;gt;= '155127' ) or erdat &amp;gt; '20081123' )  "lower limit date and time
and   ( ( erdat = '20081124' and erzet &amp;lt;= '190000' ) or erdat &amp;lt; '20081124' ).   "upper limit date and time

sort lt_vbak by erdat erzet.
if sy-subrc eq 0.
  loop at lt_vbak assigning &amp;lt;fs_vbak&amp;gt;.
    write: / &amp;lt;fs_vbak&amp;gt;-vbeln ,&amp;lt;fs_vbak&amp;gt;-erdat ,&amp;lt;fs_vbak&amp;gt;-erzet .
  endloop.
endif.&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;&lt;/P&gt;&lt;P&gt;Vinayak Sapkal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Matt on Jan 23, 2011 6:26 PM - added  tags&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Jan 2011 13:25:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588921#M1567017</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-23T13:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Command-Date time in where clause</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588922#M1567018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So what's the issue ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Jan 2011 13:29:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588922#M1567018</guid>
      <dc:creator>Sandeep_Panghal</dc:creator>
      <dc:date>2011-01-23T13:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Command-Date time in where clause</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588923#M1567019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vinayak,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;some of the newer functionalities use time stamp fields. Time stanp fields have both date and time and are by definition transformed to UTC so that they can be compared between different local time zones. If the database table uses a timestamp, it is much easier.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The way you do it is correct and can not be simplified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To make the programming a little more transparent, you can proceed like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
  lv_lower TYPE timestamp,
  lv_upper TYPE timestamp.
  CONVERT DATE '20081123' TIME '155127' 
    INTO TIME STAMP lv_lower TIME ZONE sy-zonlo.
  CONVERT DATE '20081124' TIME '190000' 
    INTO TIME STAMP lv_upper TIME ZONE sy-zonlo.

SELECT vbeln erdat erzet INTO ls_vbak
   from vbak.
  CONVERT DATE ls_vbak-erdat TIME ls_vbak-erzet 
    INTO TIME STAMP lv_timestamp TIME ZONE sy-zonlo.
  CHECK lv_timestamp BETWEEN lv_lower AND lv_upper.
  APPEND ls_vbak TO lt_vbak.
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Jan 2011 14:16:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588923#M1567019</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-01-23T14:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Command-Date time in where clause</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588924#M1567020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But don't proceed like that, as it shifts the where selection to within the loop, and will &lt;EM&gt;hammer&lt;/EM&gt; performance (on any suitable large table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd still like the original poster specify what his problem is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Jan 2011 17:29:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588924#M1567020</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2011-01-23T17:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Command-Date time in where clause</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588925#M1567021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vinayak,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why dont you try like this,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
types: begin of ty_vbak,
        vbeln type vbak-vbeln,
        erdat type vbak-erdat,
        erzet type vbak-erzet,
       end of ty_vbak.
data: lt_vbak type table of ty_vbak.
data: erdat_low type vbak-erdat.
data: erdat_high type vbak-erdat.

select vbeln erdat erzet into table lt_vbak
from vbak 
where erdat between erdat_low and erdat_high.

delete it_vbak where erzet &amp;gt;= '155127' and erdat = erdat_low.
delete it_vbak where erzet &amp;lt;= '190000' and erdat = erdat_high.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Dileep .C&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jan 2011 02:42:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588925#M1567021</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-24T02:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Command-Date time in where clause</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588926#M1567022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not leave it as it is? The where clause is perfectly ok. All other suggestions are slower. Moved to performance so others can despair...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jan 2011 05:37:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588926#M1567022</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2011-01-24T05:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Command-Date time in where clause</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588927#M1567023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks mat, i also found where clause is faster than other suggestions. I am using where clause only.&lt;/P&gt;&lt;P&gt;I tried to explore any new techniques available, but found &lt;STRONG&gt;where clause&lt;/STRONG&gt; is only right answer as performance per say.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vinayak Sapkal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jan 2011 05:45:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588927#M1567023</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-24T05:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Command-Date time in where clause</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588928#M1567024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is a relief. Thank-you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jan 2011 05:46:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-command-date-time-in-where-clause/m-p/7588928#M1567024</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2011-01-24T05:46:13Z</dc:date>
    </item>
  </channel>
</rss>

