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: 

Finding a function to get leap year

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Manohar2u
Active Contributor
0 Kudos

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

0 Kudos

PL check this

Regards,

Suresh Datti

0 Kudos

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