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: 

select statement

Former Member
0 Kudos

hi all ,

how the below select statement can be written and executed properly

select start date

end date

from ztable

where startdate - 7 LE sy-datum

and endate + 7 GE sy-datum

???

In the where condition i need to subtract and add 7

How can this be done ?

Please give your useful suggestions

6 REPLIES 6

former_member184119
Active Contributor
0 Kudos

>

> hi all ,

> how the below select statement can be written and executed properly

>

> select start date

> end date

> from ztable

> where startdate - 7 LE sy-datum

> and endate + 7 GE sy-datum

>

> ???

> In the where condition i need to subtract and add 7

>

> How can this be done ?

> Please give your useful suggestions

DATA: sdata type sy-datum , edate type sy-datum.

sdata = startdate-7 .

edate = enddate+ 7.

select start date

end date

from ztable

where sdate LE sy-datum

and edate GE sy-datum

Hope this will solve the problem

Regards

SaS

0 Kudos

thnkx all solved

Former Member
0 Kudos

You can use local variables to store dates (startdate - 7) and (endate + 7) and use these local variables in select query.

l_date1 = startdate - 7

l_date2 = endate + 7

select start_date

end_date

from ztable

where l_date1 LE sy-datum

and l_date2 GE sy-datum.

Regards,

Aparna

Former Member
0 Kudos

Hi

try like this

DATA : lv_startdate type sy-datum,lv_ endate type sy-datum

lv_startdate = startdate - 7

lv_ endate = endate + 7

select start date

end date

from ztable

where lv_startdate LE sy-datum

and lv_ endate GE sy-datum

Former Member
0 Kudos

If i'm not assuming correctly, you need a record that is valid for the last seven days and until next 7 days or more

How about .


select start date 
end date
from ztable 
where startdate LE sy-datum - 7  " Store this in a local variable
and    endate    GE sy-datum + 7 " Store this in a local variable

regards,

Advait

Former Member
0 Kudos

Hi,

you canNOT manipulate the field itself which you are putting in the WHERE clause ,but you can only manipulate the value with which you are comparing.

you cannot Do:

where startdate - 7 LE sy-datum

and endate + 7 GE sy-datum

but you can do like:

data:st_date type sy-datum,

ed_date type sy-datum.

st_date = sy-datum - 7.

ed_date = sy-datum + 7.

where startdate LE st_date

and endate GE ed_date.

Because your requirement is not clear as to which date range event you want.

assumin gthat you want Records between 7 Days back and 7 days from now.

Regards,

Neha

Edited by: Neha Shukla on Dec 3, 2008 5:03 PM