Application Development and Automation 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: 
Read only

Problem with date range

Former Member
0 Likes
1,227

Hi Friends,

I want to write a select querry with the date limit example: want to select data till particular date, How can I write it. Can any one tell me how to tell me.

Thanx in advance

Line

9 REPLIES 9
Read only

Former Member
0 Likes
1,190
parameters : p_date like sy-datum

select field1 field2 into table itab from ztable where date LE p_date.
Read only

0 Likes
1,190

Thanx for your reply,

I need to collect the data in the internal table till 31.03.2006 how can I write the select querry.

Thanx in advance,

Line

Read only

0 Likes
1,190

Give your input for P_DATE as 31.03.2006

Read only

Former Member
0 Likes
1,190

Hi,

If this Date is a Select-option field then

Select field1 field 2 field 3 into table Itab from XXX

where Date<b> in</b> S_DATE.

If the date is not a Select-option, then

Select field1 field 2 field 3 into table Itab from XXX

where Date between DATE1 and DATE2.

Regards

Sudheer

Read only

Former Member
0 Likes
1,190

Hi,

You an write using relational operators.

select *
    into lt_mkpf
   from mkpf
 where budat LE p_date.

Regards

Bhupal Reddy

Read only

Former Member
0 Likes
1,190

Hi

You can add that condition in where statement.

For the standard tables date format is like YYYYMMDD.

so you can give like WHERE endda LE 20060331 . This will fetch upto required date.

Special cases check the date format in table and give it in where condition using less then (LE) or greater than(GE).

By

Yuvaram

Read only

Former Member
0 Likes
1,190

Hi

U can create two parameter: one for date from and one for date to.

PARAMETERS: P_FROM TYPE SY-DATUM,
                         P_TO      TYPE SY-DATUM.

AT SELECTION-SCREEN.

    IF P_TO < P_FROM.
       MESSAGE E208(00) WITH 'Dates are wrong'.
    ENDIF.

START-OF-SELECTION.

    SELECT * FROM <TABLE> WHERE DATE => P_FROM AND
                                                           DATE <= P_TO

Max

Read only

Former Member
0 Likes
1,190

use WHERE extension of select statemet.

tables: vbak.

parameters : s_date like sy-datum.

data: begin of itab occurs 0,

vbeln like vbak-vbeln,

erdat like vbak-erdat,

end of itab.

select vbeln erdat from vbak into table itab up to 5 rows <b>WHERE</b> erdat <b>LT</b>

s_date.

if sy-subrc eq 0.

loop at itab.

write:/ itab-vbeln, itab-erdat.

endloop.

endif.

Read only

0 Likes
1,190

Hi,

How Can I assign date to the particular variable.

Line