This code snippet appears to be from a low-code/no-code platform,...

September 2, 2025 at 10:11 AM

formatDateTime(addDays(if(empty(outputs('Compose_OOFEndDate')), utcNow(), outputs('Compose_OOFEndDate')), if(or(equals(dayOfWeek(addDays(if(empty(outputs('Compose_OOFEndDate')), utcNow(), outputs('Compose_OOFEndDate')), 0)), 6), equals(dayOfWeek(addDays(if(empty(outputs('Compose_OOFEndDate')), utcNow(), outputs('Compose_OOFEndDate')), 1)), 0)), 2, 1)), 'yyyy-MM-dd')

This code snippet appears to be from a low-code/no-code platform, such as Microsoft Power Automate or Logic Apps, which uses expressions written in a function-based language. It performs the following operations in sequence:

  1. Retrieve the OOF End Date or Use Current Date:

    • outputs('Compose_OOFEndDate'): Refers to the value of the "Compose OOFEndDate" step.
    • empty(outputs('Compose_OOFEndDate')): Checks if this value is empty.
    • if(empty(outputs('Compose_OOFEndDate')), utcNow(), outputs('Compose_OOFEndDate')): If the value is empty, it substitutes the current UTC date and time (utcNow()); otherwise, it uses the provided "OOFEndDate" value.
  2. Add Variable Days to the Date:

    • The inner addDays() is used to calculate a new date by adding days. It evaluates whether to add 0 days or more, depending on the conditions that follow.
  3. Check for Weekends and Adjust:

    • dayOfWeek(...): Determines the day of the week for the calculated/current date (0 = Sunday, 1 = Monday, ..., 6 = Saturday).
    • or(equals(dayOfWeek(...), 6), equals(dayOfWeek(...), 0)): Checks if the date is a weekend (Saturday or Sunday).
    • if(..., 2, 1): If the day is a weekend, it adds 2 days to shift it to the following Monday. If not, it adds 1 day.
  4. Combine Adjustments:

    • The above logic is wrapped in another addDays() to adjust the original date obtained in step 1 by the calculated number of days (either 1 or 2, depending on whether the date falls on a weekend).
  5. Format the New Date:

    • formatDateTime(..., 'yyyy-MM-dd'): After computing the adjusted date, it formats the date into the yyyy-MM-dd format (e.g., "2023-10-18").

Summary:

This code evaluates the "Compose OOFEndDate" value. If it is empty, it uses the current date and time. It then adjusts this date:

  • If the date falls on a Saturday or Sunday, it adds 2 days.
  • Otherwise, it adds 1 day. Finally, the adjusted date is formatted as a string in the yyyy-MM-dd format.
Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node