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

SELECT BY DATE

Former Member
0 Likes
1,585

Can someone assist with how to select dates for a table based on the criteria that the offset is 5 and if at that offset the number is less than 2 e.g. 20.07.1998 would be selected and 20.07.2007 will not.

thanx in advance

8 REPLIES 8
Read only

Former Member
0 Likes
1,018

Hi,

Do you mean to check whether the date is before 01.01.2000? Or am I thinking wrong?

Regards, Joerg

Read only

Former Member
0 Likes
1,018

variable = date - 2. "2 is your offset

use the variable in your select condition.

Read only

Former Member
0 Likes
1,018

Hi,

I hope you want to Retrieve the date from year 1998 only.

Then use this select command with appropriate changes.

SELECT * FROM Table_Name INTO TABLE it
WHERE spras = sy-langu
AnD date LIKE '%1998%'.

Thanks,

Reward If Helpful.

Read only

0 Likes
1,018

Hi,

If it is an ABAP DATE field (in SAP-supplied tables it should be), then


SELECT * FROM table WHERE date lt '20000101' ...

should suffice.

Regards, Joerg

Read only

Former Member
0 Likes
1,018

Hi Darlington,

First you select all the dates into your internal table.

What i mean to say is, use selection criteria to pick data from your data base table.

after fetching all the records check whether the date field's first character

if it is '2' then delete that record from the internal table.

<b>Example1:</b>

tables: pa0000.

data: begin of itab occurs 0,

begda like pa0000-begda,

end of itab.

select begda from pa0000 into table itab.

if sy-subrc = 0.

sort itab by begda.

<b>delete itab where begda+0(1) eq '2'.</b>

endif.

<b>Also check another example:</b>

System stores data as 'YYYYMMDD' format.

data: v_date1 type sy-datum value '19980720'.

data: v_date2 type sy-datum value '20070720'.

if v_date1+0(1) ge '2'.

write:/ 'Not a valid date'.

else.

write:/ 'Valid date'.

endif.

if v_date2+0(1) ge '2'.

write:/ 'Not a valid date'.

else.

write:/ 'Valid date'.

endif.

Read only

0 Likes
1,018

Let me put it straight. The problem is, some dates in the DKKKOP table for fields FAEDN and FAEDS are appearing reversed. e.g. 01.08.2007 is appearing as 20.07.0801. So I would like to search using the fifth offset to search for char less than 2.

Read only

0 Likes
1,018

If you say for some records the date is 20.07.0801, then I would be asking who in your company has done a direct update to the table and got it wrong.

Read only

Former Member
0 Likes
1,018

thanx all. you have been of great help