News:

  • February 01, 2023, 10:32:48 AM

Login with username, password and session length

Author Topic: EXAMPLE: Detect a Leap Year and specify last of February (Suggestion?)  (Read 537 times)

Mike@Forshock

  • Sr. Member
  • ****
  • Posts: 55
Had to create a quick function to detect a leap year to run functions on the last day of the month.
Searched the manual really quick and did not find any reference, so made a quick MATH instruction and inserted a formula.

This formula outputs the total days in February, which is then compared to determine if we have 365 or 366 days for other functions.

YearToCheck: Unsigned Word or other numeric representing the year to compare (4-digit)

Code: [Select]
IF((YearToCheck % 4) != 0, 28, IF(((YearToCheck % 400) == 0) | ((YearToCheck % 100) != 0), 29, 28))

Suggestion: Add to the SDT/UDT structure the days in February calculated without addon code?




There are no comments for this topic. Do you want to be the first?