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: 

Is there any way can find out is that date falling between two dates?

Former Member
0 Kudos
101

Hi All-

I need to know from you guy's is there any way we can know is that date is falling between two dates...

For Example: p_date = 03/10/2007

p_date1 = 03/10/2006

another date = 11/10/2006 -


So, Now this date is falling between these two dates...I want to know, how to find out that?

Please give me solution...

Thanks,

Sony

4 REPLIES 4

suresh_datti
Active Contributor
0 Kudos
87

Use the code..

If p_date le p_date2 and p_date ge p_date1.

    • p_date is between the two dates

endif.

~Suresh

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
87

There are a few ways to do this, one of the easiest is to do something like this.

data: p_datum type sy-datum.
data: p_datum_begin type sy-datum.
data: p_datum_end type sy-datum.

if p_datum => p_datum_begin
     and p_datum <= p_datum_end.

Endif.

Again, there are a few more ways to do this.

Regards,

RIch Heilman

ferry_lianto
Active Contributor
0 Kudos
87

Hi,

Please try this.


DATA: P_DATE1 LIKE SY-DATUM VALUE '20061006',
      P_DATE2 LIKE SY-DATUM VALUE '20071003',
      V_DATE  LIKE SY-DATUM VALUE '20061011'.
                                                                        
CHECK V_DATE BETWEEN P_DATE1 AND P_DATE2.
WRITE: / 'INPUT DATE IS BETWEEN TWO DATES'.

Regards,

Ferry Lianto

former_member181962
Active Contributor
0 Kudos
87

HI Sony,

One more way.

ranges r_date for sy-datum.

r_date-sign = 'I'.
r_date-option = 'BT'.
r_date-low = p_date1.
r_date-high = p_date2.
append r_date.
clear r_date.

if another_date in r_date.
* Your date falls in that range
endif.