Forum Discussion

dhundley's avatar
dhundley
Regular Contributor
3 years ago
Solved

aqDateTime AddYears

is there a reason why aqDateTime does not appear to have an AddYears method? Seems to have everything but that (AddSeconds, AddMinutes, AddHours, AddDays and AddMonths as well as an AddTime that let's you add or subtract days, hours, minutes and second). Can anyone share with me how i can add two years to a date? 

 

Thanks

4 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    You can use for example,

    function NextYear()
    {
        const aYearFromNow = new Date();
        aYearFromNow.setFullYear(aYearFromNow.getFullYear() + 1);
        Log.Message(aYearFromNow);
    }
  • dhundley's avatar
    dhundley
    Regular Contributor

    it did just occur to me that i could use the AddMonths and specify a value of 24. if my starting date is the first day of a month will adding 24 months keep the new date on the first? i'll try it out and see but it just seems odd that there wouldn't be an AddYears. How difficult would it be to include it?