Skip to Content
author's profile photo Former Member
Former Member

data fetching comparing dates.

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    Posted on Aug 06, 2009 at 09:41 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 06, 2009 at 09:29 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 06, 2009 at 09:33 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    Former Member
    Posted on Aug 06, 2009 at 09:38 AM

    thank u...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 06, 2009 at 09:45 AM

    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,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2009 at 11:25 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.