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: 

data fetching comparing dates.

Former Member
0 Kudos

there are 2 fields in the table

Beginging and End date

for every employee there r two or more rows.

In my selection screen i m selecting month and year.i want to fetch only that row for a employee which comes in date range.

for example

selection screen

month 05

year 2009

beg end

04/2008 09/2008

10/2008 09/2009

so it shud select the second row.

thanks.

Edited by: aks on Aug 6, 2009 5:25 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Well one way of doing it is concatenate the month and year and pass it to the select statement.



data: dat(6) type c.

concatenate year month into date.

select * 
from Dbtable 
into itab
where begda <= date and 
        endda >= date.

Regards,

Vik

9 REPLIES 9

Former Member
0 Kudos

Hi,

you can put logic in the following way...

SELECT SINGLE exmpt FROM t5u13

INTO t5u13-exmpt

WHERE stell = p0001-stell AND

begda <= p_prcdte AND

endda >= p_prcdte.

Thanks

Ashu

viquar_iqbal
Active Contributor
0 Kudos

Hi

Use offsets.

READ TABLE itab WITH TABLE KEY beg4(4) <= year end4(4) >= year.

If sy-subrc eq 0.

display record.

endif.

Hope this resolves your query.

Viquar Iqbal

0 Kudos

READ TABLE itab WITH TABLE KEY beg4(4) <= year end4(4) >= year.

reln. operator <= not working pls help...

0 Kudos

Hi,

The relational operator <= wont work for read statement. This is the easy way to do it



data: date(6) type c.
 
concatenate p_year p_month into date.
 
select * 
from Dbtable 
into itab
where begda <= date and 
        endda >= date.

The relational operator can be used with IF condition. Not read statements.

Regards,

Vik

Former Member
0 Kudos

thank u...

Former Member
0 Kudos

Hi,

Well one way of doing it is concatenate the month and year and pass it to the select statement.



data: dat(6) type c.

concatenate year month into date.

select * 
from Dbtable 
into itab
where begda <= date and 
        endda >= date.

Regards,

Vik

Former Member
0 Kudos

Hi Friend ,

**************************if it is a date***********************

1. Using that month and year get the first date and last date of the month .

2. Create range field for date .

3. Populate the begi date in low value and ending date in high value.

4. In you select query

select <fields>

from <table>

into <itab>

where beg <= rang_date-low and

end >= rang_date-high.

********************************if it is a period ********************************************************

1. Concatenate the month and year .

2. select query

select <fields>

from <table>

into <itab>

where beg <= Period and

end >= period .

thanks,

Former Member
0 Kudos

but wat if i want to compare year from the date beg+4(4) <= year

0 Kudos

Then use the if condition instead of read



loop at itab.
if itab-beg+4(4) <= year itab-end+4(4) >= year.
display record.
endif.
endloop.

Regards,

Vik