‎2007 May 30 7:08 PM
I would like to do select in my database table like this:
select * from abc_table
where dtret - dt_current = 6.
where:
dtret is a date field in table,
dt_current has sy-datum.
I can do this? dtret - dt_current works well in all the cases? Or I have to use some function?
Thanks
‎2007 May 30 7:19 PM
Hi,
Please try this.
DATA: WA_DATE LIKE SY-DATUM.
WA_DATE = SY-DATUM - 6.
SELECT *
INTO TABLE ITAB
FROM ABC_TABLE
WHERE DTRET = WA_DATE.
Regards,
Ferry Lianto
‎2007 May 30 7:09 PM
Sorry, I forgot to mention that I need to receive the delta in days.
‎2007 May 30 7:19 PM
Hi,
Please try this.
DATA: WA_DATE LIKE SY-DATUM.
WA_DATE = SY-DATUM - 6.
SELECT *
INTO TABLE ITAB
FROM ABC_TABLE
WHERE DTRET = WA_DATE.
Regards,
Ferry Lianto
‎2007 May 30 7:19 PM
I don't think it is possible.
You can fetch the data first in an internal table.
LOOP through internal table and find out the difference between dtret and dt_current and if it is not equal to 6, delete this record from internal table.
‎2007 May 30 7:19 PM
Hi
You can do this way.
Have a variable of type <b>sy-datum</b> and assign value as <b>sy-datum - 6</b>.
Then use this variable in WHERE condition as
<b>WHERE dtret = <your variable>.</b>
Regards,
Raj
‎2007 May 31 4:22 AM
Hi Cristiana,
Apply the below code I guess it will solve your problem.
Select * into table itab from abc_table
where dtret NE sy-datum.
LOOP at itab.
IF sy-subrc EQ 0.
dt_current = itab-dtret - dt_current.
IF dt_current EQ 6.
MOVE itab TO itab1.
APPEND itab1.
ENDIF.
ENDIF.
ENDLOOP.
Reward points to all useful answers.
Regards,
SaiRam
‎2007 May 31 7:09 PM
My problem is that my abc_table has a looooooot of records....
So I would like to read to my internal table only those ones that match....
‎2007 May 31 7:16 PM
I think Ferry's example is exactly what you are looking for. Have you tried it?
Rob