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

Finding a function to get leap year

Former Member
0 Likes
1,970

Hi everybody!

I need a function or code to find if a year is leap year or normal year.

Thanks a lot of!

DM

Hi everybody!

I need a function or code to find if a year is leap year or normal year.

Thanks a lot of!

DM

4 REPLIES 4
Read only

Former Member
0 Likes
1,010

I don't know of one - but it is quite an easy calculation so you could maybe write your own.

A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400.

Message was edited by: Barbara McCallum

Read only

Manohar2u
Active Contributor
0 Likes
1,010

Hi

Please check the below FM, to get days between 2 dates.

You can use the logic behind to build Z FM if this is not as per your requirement.

FIMA_LEAP_DAYS_BETWEEN_2_DATES

LEAP_DAYS_BETWEEN_TWO_DATES

Regds

Manohar

Read only

0 Likes
1,010

PL check this

Regards,

Suresh Datti

Read only

0 Likes
1,010

Here is some code that I had in my bag of tricks.



report zrich_0001 .
parameters: p_datum type  sy-datum.
* check if it is a leap year.
data: march1 type sy-datum.
data: last_day_feb type sy-datum.

march1 = p_datum.
march1+4(4) = '0301'.
last_day_feb = march1 - 1.
if last_day_feb+6(2) = '29'. 
 write:/ 'This is a leap year'.
endif.

Regards,

Rich Heilman