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

Function to get the exact date

Former Member
0 Likes
721

Hi Gurus,

I am searching for a function to get the exact date for certain year.

For example, I would like to know the exact date after 3 years from today.

Because we need to consider the leap year, therefore I cannot do it in this way:

365 (days) * 3 Year(s)

Any suggestion which function I can use here?

All ideas and suggestion are greatly appreciated.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
680

Hi,

You can use the FM RE_ADD_MONTH_TO_DATE

code

DATA: V_DATE TYPE SYDATUM.

V_DATE = SY-DATUM.

CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'

EXPORTING

MONTHS = '36'

OLDDATE = V_DATE

IMPORTING

NEWDATE = V_DATE.

WRITE: / 'After 3 Years', V_DATE.

Thanks

4 REPLIES 4
Read only

former_member386202
Active Contributor
0 Likes
680

Hi,

Use FM RE_ADD_MONTH_TO_DATE

Regards,

Prashant

Read only

Former Member
0 Likes
681

Hi,

You can use the FM RE_ADD_MONTH_TO_DATE

code

DATA: V_DATE TYPE SYDATUM.

V_DATE = SY-DATUM.

CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'

EXPORTING

MONTHS = '36'

OLDDATE = V_DATE

IMPORTING

NEWDATE = V_DATE.

WRITE: / 'After 3 Years', V_DATE.

Thanks

Read only

0 Likes
680

Thank you so much for the answers.

Especially to Anurodh Jindal, whose provide the example to me as well.

Thanks to all.

Read only

0 Likes
680

Hi Gurus,

I understand that the above function is used for calculate the date after added certain month(s).

But, how do I do it in the other way. What I mean here is I want to substract the date.

For example my current date is 09.05.2008, substract 3 years is 09.05.2005.

All ideas and suggestion are greatly appreciated.

Thanks.