Skip to Content
0
Former Member
Jan 23, 2011 at 01:25 PM

SQL Command-Date time in where clause

1478 Views

Hi friends

complecated SQL command for fetching records using where clause of Date and Time - (if using Select option).

Very Helpfull.

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: <fs_vbak> type ty_vbak.

select vbeln erdat erzet into table lt_vbak
from vbak
where ( ( erdat = '20081123' and erzet >= '155127' ) or erdat > '20081123' )  "lower limit date and time
and   ( ( erdat = '20081124' and erzet <= '190000' ) or erdat < '20081124' ).   "upper limit date and time

sort lt_vbak by erdat erzet.
if sy-subrc eq 0.
  loop at lt_vbak assigning <fs_vbak>.
    write: / <fs_vbak>-vbeln ,<fs_vbak>-erdat ,<fs_vbak>-erzet .
  endloop.
endif.

Regards

Vinayak Sapkal

Edited by: Matt on Jan 23, 2011 6:26 PM - added tags