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

Getting dates between given date range

Former Member
0 Likes
12,622

Hi All,

For a given date range in the selection screen i need to find all the dates in between that range into one internal table.

Eg: if i give the date as 21.09.2009 to 20.10.2009 then for this date range in need to get all the dates in between that date range

in one internal table.

Is there any fundtion module to fullfill such a requirement. Please do the needful help.

Thanks

Shashikanth Naram

1 ACCEPTED SOLUTION
Read only

Former Member
5,857

why do you need all dates. if you need some kind of range you can use between abc and def. or you can create a range table as well.

any ways for your purpose.

DATA: dt1 type sy-datum VALUE '20090910'.
DATA: dt2 type sy-datum VALUE '20090918'.
DATA : i1 type i.
i1 = dt2 - dt1.
data : it1 type TABLE OF sy-datum WITH HEADER LINE.
do i1 TIMES.
  it1 = dt2.
  dt2 = dt2 - 1.
  APPEND it1.
enddo.

LOOP AT it1.
  WRITE :/ it1.
ENDLOOP.

10 REPLIES 10
Read only

Former Member
0 Likes
5,857

v_first_date = '21.09.2009' .

wa_date = v_first_date.

append wa_date to t_date.

while date <= '30.10.2009'

wa_date = wa_date + 1

append wa_date to t_date.

endwhile.

This should work. Good luck.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
5,857

Hello Pranu,

This should work. Good luck.

You should wish him luck 'coz the code will lead him in to the trap of "infinite loop".


v_first_date = '21.09.2009' .
wa_date = v_first_date.
append wa_date to t_date.

" while date <= '30.10.2009'
while wa_date <= '30.10.2009'.
wa_date = wa_date + 1
append wa_date to t_date.
endwhile.

Cheers,

Suhas

Read only

0 Likes
5,857

Fortunately Typos will be caught in Syntax check so no infinite loop.

Read only

0 Likes
5,857

Hi Suhas,

I there any solution of finding this i.e is any standard funditon module to find this...

Thanks

Shashi

Read only

0 Likes
5,857

Hi

No, I don't think there's a fm to obtain it, u need to use a solution developed by yourself

Max

Read only

Former Member
5,858

why do you need all dates. if you need some kind of range you can use between abc and def. or you can create a range table as well.

any ways for your purpose.

DATA: dt1 type sy-datum VALUE '20090910'.
DATA: dt2 type sy-datum VALUE '20090918'.
DATA : i1 type i.
i1 = dt2 - dt1.
data : it1 type TABLE OF sy-datum WITH HEADER LINE.
do i1 TIMES.
  it1 = dt2.
  dt2 = dt2 - 1.
  APPEND it1.
enddo.

LOOP AT it1.
  WRITE :/ it1.
ENDLOOP.

Read only

Former Member
5,857

Hi Sashi,

Just have a look at this link below.

https://wiki.sdn.sap.com/wiki/display/ABAP/FunctionModulerelatedonDate+calculations

It gives the list of all the date related FM's. Maybe something can be of help to your requirement.

Thanks,

Harini

Read only

0 Likes
5,857

Hi passerby,

Here is the correct link.

Regards,
Nemanja

Read only

Former Member
0 Likes
5,857

USE THE FUNCTION MODULE

DAY_ATTRIBUTES_GET

IF IT DOESNT WORK USE

'HR_99S_INTERVAL_BETWEEN_DATES Difference ' AND INCREMENT MONTS AND YEARS

DEFINETLY YOU WILL GET OUTPUT

Read only

viva_kd
Participant
0 Likes
5,277

Dear all, thanks for this query ,thanks my efforts got reduced. this FM DAY_ATTRIBUTES_GET
it resolved my purpose and does exact same, as asked in query, just give start and end date, it will give List of ALL dates between given input 2 dates .. very gratefull.