10 Replies Latest reply on Feb 10, 2017 5:34 AM by weedonpaul

    Dealing with leap years in accounts




      I have to submit VAT returns end of FEB, MAY, AUG and NOV


      I am want the user to select month and year from drop down lists to be used in a script to calculate the VAT return, both month and year are stored as text in a lookup table


      I want it so that the choice is then changed into a date format of the last day of the month


      eg user selects MAY and 2017 it returns 31/05/2017


      The problem is February and leap years


      My solution is to go to the first of the following month and subtract 1


      user selects FEB and 2017 it returns (01/03/2017)-1 and stores it as 28/02/2017

      user selects FEB and 2020 it returns (01/03/2017)-1 and stores it as 29/02/2020


      will that work? and how would I go about it?