Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Search via date field

Former Member
0 Kudos
100

Hello All,

I have to search record from the DB via date field in such a way that

suppose this mounth is aug. then i have to search all record created on aug

no matter in which year it was created.

Thanks

3 REPLIES 3

former_member589029
Active Contributor
0 Kudos
78

Try this way:


DATA: lt_vbak   TYPE TABLE OF vbak,
      lv_date(8) TYPE c.

lv_date      = sy-datum.
lv_date(4)   = '____'.
lv_date+6(2) = '__'.

SELECT * FROM vbak
       INTO TABLE lt_vbak
       WHERE erdat LIKE lv_date.

This will only return orders created in the current month regardless of day or year.

Regards,

Michael

Former Member
0 Kudos
78

Hi,

Check the code

DATA: T_flight TYPE TABLE OF SFLIGHT,
      DATE TYPE SY-DATUM,
      DATE_TEMP(2) TYPE C,
      DATE_CHECK(8) type c.

DATE = SY-DATUM.
DATE_TEMP = DATE+4(2).

concatenate '____' DATE_TEMP '__' INTO DATE_CHECK.   
                 "( 1st string consist of 4 underscore 
                 " and 3rd string has 2 underscore,    
                 "  as _ is the escape char for single char in open SQL )
SELECT *
  FROM SFLIGHT
  INTO TABLE t_FLIGHT
 WHERE FLDATE like DATE_CHECK.

Regards,

anirban

Former Member
0 Kudos
78

Hi,

While searching for record in select statement just compare months. like

select *

from <db table>

into table <itab>

where s_date4(2) eq db_field4(2).

where s_date in the date entered by you and db_field is the date field which you want to compare.

Hope this will give some idea,

Regards,

Aswini.