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

how to retrive data between two dates

Former Member
8,221

Hi Guru's

i want to retrive data between two finish date and start date.

i write following code but this code work not properly.

select gltrp gstrp aufnr from afko into corresponding fields of table

itab1 where aufnr in orderno and gstrp in FINISHDT

and gltrp in STARTDT.

please suggest me.

Regard

sam.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,824

Hi Sam

Do it like this:

and make sure you are also including date field in the selection and you ca ngive the date range in select option.

select gltrp gstrp aufnr gstrp from afko into corresponding fields of table

itab1 where aufnr in orderno and gstrp eq p_start and gltrp eq p_finish.

Regards

Neha

Edited by: Neha Shukla on Dec 1, 2008 6:12 PM

7 REPLIES 7
Read only

Former Member
0 Likes
2,824

Hello,

begda -> begin date.

endda -> enddate.

where begda <= sy-datum

and endda >= sy-datum.

Above statement will fetch the data valid today.

Hope it helps.

Thanks,

Jayant

Read only

rainer_hbenthal
Active Contributor
0 Likes
2,824

As you didnt tell how the two ranges table are filled no one can help you. I would suggest to take less then and reater then instead range tables.

Read only

Former Member
0 Likes
2,824

Hi

Use BETWEEN in the WHERE clause

Hope this will solve your problem

Regards

Ramchander Rao.K

Read only

Former Member
0 Likes
2,825

Hi Sam

Do it like this:

and make sure you are also including date field in the selection and you ca ngive the date range in select option.

select gltrp gstrp aufnr gstrp from afko into corresponding fields of table

itab1 where aufnr in orderno and gstrp eq p_start and gltrp eq p_finish.

Regards

Neha

Edited by: Neha Shukla on Dec 1, 2008 6:12 PM

Read only

Former Member
0 Likes
2,824

first u get first and last date useing following FM

'FIRST_AND_LAST_DAY_IN_YEAR_GET'

Read only

Former Member
0 Likes
2,824

select gltrp gstrp aufnr from afko into corresponding fields of table

itab1 where aufnr in orderno and (gstrp >= STARTD and gstrp <= FINISHDT).

Regards,

Ajay

Read only

Former Member
0 Likes
2,824

Hi Sam,

Use BETWEEN in WHERE clause of your SELECT query.

select gltrp gstrp aufnr from afko into corresponding fields of table
itab1 where aufnr in orderno and gstrp between STARTDT and FINISHDT.

With luck,

Pritam.