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: 

year from date field

Former Member
0 Kudos

hi

in cdhdr table udate field is there. i want to retrieve the records belong to 2007

only. when i am using offset on udate field as udate+0(4) in the select statement it is showing error. plz tell me how to retrieve only year form udate field in select stament.

regards

sami

1 ACCEPTED SOLUTION

Former Member
0 Kudos

select * from cdhdr into table itab where udate like '2007%'.

regards

shiba dutta

6 REPLIES 6

Former Member
0 Kudos

select * from cdhdr into table itab where udate like '2007%'.

regards

shiba dutta

0 Kudos

i don't want to hard code 2007. the select statment is

select * from cdhdr

where udate = sy-datum+0(4).

so know how to write the statment to compare the year.

0 Kudos

ok then take a char field

data : yr(5).

concatenate sy-datum+0(4) '%' into yr.

now use

select * from cdhdr into table itab where udate like yr.

regards

shiba dutta

Former Member
0 Kudos

you can not fetch like that you need to fech total date then conver it to only year

select udate

from cdhdr

into gt_cdhdr.

loop at gt_cdhr.

gt_cdhr-udate = gt_cdhr-udate+0(4)

modify gt_cdhr transporting udate.

endloop.

Rewards if useful.........

Minal Nampalliwar

varma_narayana
Active Contributor
0 Kudos

Hi...

You can use the LIKE Operator in this Case for checking the conditions.

Eg

Select * from CDHDR into table itab where Udate LIKE '2007%'.

To access the Year field only use...

SELECT udate(4) FROM cdhdr.....

<b>reward if Helpful.</b>

Former Member
0 Kudos

You can use 'Select * from CDHDR where udate like '2007%'.

Reward the points if it is useful.