ADF Expression to Determine the First Weekday of Each Month

Dáre Soniran 20 Reputation points
2025-04-16T14:57:37.02+00:00

The goal is to create a pipeline that runs only on the first weekday of each month. Since a trigger schedule is not applicable due to the need for the pipeline to run between days 1-5 of each month, an expression is needed to identify the first weekday.

The current expression being used is:

@string(and(equals(daysofMonth(utcnow(),1), contains('12345',string(daysOfWeek(utcnow()))))

The objective is to evaluate if the current day matches the determined first weekday to continue with the pipeline and trigger alerts without redundancy.

Any guidance on how to correctly build this expression would be appreciated. Thank you!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,639 questions
{count} votes

Accepted answer
  1. Nandan Hegde 36,151 Reputation points MVP Volunteer Moderator
    2025-04-16T16:23:49.68+00:00

    Below can be the condition :

    1. 1st of the day falls between Mon-Friday
    2. 1st is Sat
    3. 1st is Sun

    So use an OR condition for the above 3 to determine whether getdate is equivalent to 1st week day

    below expression might work :

    @or(or(and(equals(dayOfMonth(utcNow()), 1), lessOrEquals(dayOfWeek(utcNow()), 5)),
        and(equals(dayOfMonth(utcNow()), 2), equals(dayOfWeek(addDays(utcNow(), -1)), 6))),
        and(equals(dayOfMonth(utcNow()), 3), equals(dayOfWeek(addDays(utcNow(), -2)), 6))
    )
    
    
    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Dáre Soniran 20 Reputation points
    2025-04-17T11:57:47.3033333+00:00

    Hi Nanden and Venkat,

    Thanks for your replies.

    The solution found was multiple if conditions as suggested by @Nandan Hegde

    1. SetVariable - Day1
    2. If condition - CheckWeekday
    @contains(
    	'12345'
    	string(dayOfWeek(startOfMonth(utcNow())))
    )
    
    

    2a. If true - setVariable for BusinessDay = Day1

    1. If condition - CheckSaturday
    @contains(
    	'6'	
    	string(dayOfWeek(startOfMonth(utcNow())))
    )
    

    3a. If true - setVariable for BusinessDay = addDays(Day1,2)

    1. If condition - CheckSunday
    @contains(
    	'0'	
    	string(dayOfWeek(startOfMonth(utcNow())))
    )
    

    4a. If true - setVariable for BusinessDay = addDays(Day1,1)

    1. If Condition - BusinessDay=Today

    5a. If true - execute secondary pipeline which will trigger alert.

    So this initial pipeline can have a scheduled trigger running from days 1-5 each month, but only trigger the alert pipeline once a month.


    However, decided to create a table in sql with columns: day,weekday,weekend,start_quarter and start_year. Then use until activity to check when weekday is flagged as true.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.