2 Replies Latest reply: May 16, 2012 11:46 AM by mrpjspencer RSS

    How to caculate days in a year factoring leapyears

      Good morning, i've a minor issue im not sure how to resolve, I am trying to calculate age of debt for our finance team.

      Ive used the script below to calculate age but not factoring in leapyears. This can lead to possible errors where a balance could span across 2 financial years.



      if(today()-Due_Date>=0 and Today()-Due_Date<=365,'0-1 Years',

           if(today()-Due_Date>=366 and Today()-Due_Date<=730,'1-2 Years',

           if(today()-Due_Date>=731 and Today()-Due_Date<=1096,'2-3 Years',

           if(today()-Due_Date>=1097 and Today()-Due_Date<=1461,'3-4 Years',

           if(today()-Due_Date>=1462,'4+ Years'))))) as Years



      How do I go about factoring in leap years into the script above.


      Kind regards,