12-03-2008 11:21 AM
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
12-03-2008 11:23 AM
>
> 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
12-03-2008 11:31 AM
12-03-2008 11:24 AM
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
12-03-2008 11:25 AM
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
12-03-2008 11:32 AM
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
12-03-2008 11:33 AM
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