Forum Discussion

mioani's avatar
mioani
Occasional Contributor
6 years ago
Solved

Get the date of next Sunday

Hello all,   I want to get the date of the next Sunday, of every week to be entered in a specific field. I have tried aqConvert.DateTimeToFormatStr(aqDateTime.AddDays(7), '%d.%m.%Y') as Sunday be...
  • tristaanogre's avatar
    tristaanogre
    6 years ago

    Then your code is going to need to be longer than single line.  

     

    You're going to need to know

     

    1) What the current day of the week is

    2) How many days until Sunday that is

     

    So...

     

    function getNextSunday(currentDate){
    
        var currentDOW = aqDateTime.GetDayOfWeek(currentDate);
        var daysToAdd = 8-currentDOW;
        return aqDateTime.AddDays(currentDate, daysToAdd);
    
    }