This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

calculate diferent between years, month, days
#4
Hi, I the day difference is probably due to a leap year in your start or end date, you could try to add something like this in your code:
Code:
function isLeapYear(year)
   if ((((year % 4 ==0) and (year % 100~=0)) or (year % 400==0)))then
      return true
   else
      return false
  end
end

if isLeapYear(startdate.year) then
  -- add or remove a day
  log('startdate is a leap year')
end

if isLeapYear(enddate.year) then
  -- add or remove a day
  log('enddate is a leap year')
end
Reply


Messages In This Thread
RE: calculate diferent between years, month, days - by Erwin van der Zwart - 19.04.2022, 07:30

Forum Jump: