Wanted to know how to get All Saturdays and Sundays date in a year?

Certified Associate Developer

Hi there,

I have a requirement to get the date of All Saturdays and Sundays in a year,

please let me know if there is a way to do it.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    try this

    a!localVariables(
      /* Define the year for which you want to get the dates */
      local!year: 2023,
      /* Define the start for the year */
      local!startDate: date(local!year, 1, 1),
     
      /* Get the number of days for the year*/
      local!daysInYear: if(isleapyear(local!year),366,365),
     
      /* Iterate through each day in the year */
      a!forEach(
        items: enumerate(local!daysInYear),
        expression: a!localVariables(
          /* Get the current date */
          local!date: adddays(todatetime(local!startDate), fv!item),
          /* Check if the current date is a Saturday or Sunday */
         if(
           Weekday(local!date,2) = 6 /* Saturday */,
           a!map(day:"saturday",date:todate(local!date)),
           if(
             weekday(local!date,2) = 7  /* Sunday */,
             a!map(day:"sunday",date:todate(local!date)),
             {}
           )
         )
         
        )
      ),
      /* Display the list of Saturday and Sunday dates */
    
    )
    

Reply
  • 0
    Certified Associate Developer

    try this

    a!localVariables(
      /* Define the year for which you want to get the dates */
      local!year: 2023,
      /* Define the start for the year */
      local!startDate: date(local!year, 1, 1),
     
      /* Get the number of days for the year*/
      local!daysInYear: if(isleapyear(local!year),366,365),
     
      /* Iterate through each day in the year */
      a!forEach(
        items: enumerate(local!daysInYear),
        expression: a!localVariables(
          /* Get the current date */
          local!date: adddays(todatetime(local!startDate), fv!item),
          /* Check if the current date is a Saturday or Sunday */
         if(
           Weekday(local!date,2) = 6 /* Saturday */,
           a!map(day:"saturday",date:todate(local!date)),
           if(
             weekday(local!date,2) = 7  /* Sunday */,
             a!map(day:"sunday",date:todate(local!date)),
             {}
           )
         )
         
        )
      ),
      /* Display the list of Saturday and Sunday dates */
    
    )
    

Children
No Data