Power Automate dayOfYear() Function [With Various Examples]

This Power Automate tutorial will guide you on how to work with the Power Automate dayOfYear() function. Additionally, you will see an introduction to the Power Automate dayOfYear() function, its syntax, and a few examples of it.

The dayOfYear() function in Power Automate functions similar to the dayOfMonth() function, allows us to find out the sequential day of the year from the beginning of the year of a particular timestamp.

Power Automate dayOfYear() Function

Power Automate dayOfYear() function is helpful to get the sequential day of that particular year of a provided timestamp or from a date and time. It will calculate the days between 1 to 366, irrespective of the months.

The return output value from this function will be in the form of an integer, which gives the day of the year from the specified timestamp.

Let’s say Today’s date is “15-12-2023“; then it will give the sequential day of the year that specific date. And the result will be 349, which is the 349th day out of 366 days.

Power Automate dayOfYear Function

This is a brief introduction to the Power Automate dayOfYear() function.

Power Automate dayOfYear() Function Syntax

Power Automate syntax for the dayOfYear() function is given in the below code:

dayOfYear('timestamp')

Parameters:

timestamp: It works with only one parameter required to be a String and mandatory to provide.

Example:

dayOfYear('2023-12-12')
  • 2023-12-12 = Provide a specific date.

It gives the output as ‘346‘, the sequential day of the particular year.

This function calculates results based on the period between January 1 and December 31, with no rounding applied (irrespective of month numbers).

However, an error will be returned if the datetime parameter is absent or not recognized as a valid date or time.

Power Automate dayOfYear() of utcNow

Let’s see how to get a day of a year from the current date in a Power Automate flow using the dayOfYear() function.

Example:

Let’s assume Today’s date is “15-12-2023“, and I need to know the current day’s count in a year. Then, the result will be 349, which means 349th day out of 365 days.

Power Automate dayOfYear() expression

To work around this, follow the below steps:

1. Browse https://make.powerautomate.com to open the Power Automate Home page with your Microsoft credentials. Then click +Create -> Select Instant cloud flow -> Provide a flow name & select trigger Manullay trigger a flow -> Tap Create button.

2. To initiate the string variable and assign the utcNow() value to it, please follow the instructions below:

  • Choose the “Initialize variable” action.
  • Assign a variable name and set its type as a String.
  • Set the variable’s value as utcNow() with the dayOfYear expression.

Value: Select field -> Click Expression -> Add the code -> Click OK.

dayOfYear(utcNow())
Power Automate dayOfYear() of utcNow

3. To add outputs from the initialized variable to the workflow, choose and add a Compose flow action.

Inputs: Select the field -> Select a Day of Year variable from the dynamic content.

Get Power Automate dayOfYear() of utcNow

4. Save the flow before manually testing it once it is complete. The compose flow action will extract the current date’s day of the year using the dayOfYear() function.

  • The result from the expression will be the 349th day of that particular year.
Get Power Automate dayOfYear() in days

This is how to process the day of a year of the current date using the Power Automate dayOfYear() function.

Power Automate dayOfYear() from SharePoint Date

Upon implementing the previous example, we will now see how to retrieve the day of the year from a SharePoint date column from Power Automate.

Example

I have taken a SharePoint list [Medical Camp Registration] with a date column named Date of Birth. This list has various items along with dates, as shown below:

Power Automate dayOfYear() from SharePoint Date

We wanted to extract the day of a particular year from the SharePoint date column using Power Automate. Let’s imagine a date, “22/12/2023“, which will provide the result as the 356th day of that particular year.

Power Automate dayOfYear() function

Do follow the below-mentioned steps:

1. Log into Power Automate with your Microsoft credentials -> In the Power Automate Home page, tap +Create -> Select Automated cloud flow -> Provide a flow name & select trigger When an item is created or modified -> Tap the Create button.

  • Site Address: Select a SharePoint site address from the drop-down.
  • List Name: Choose a specific SharePoint list name from the drop-down.
dayOfYear from SharePoint date in Power Automate

2. Initialize the Date of Birth column by initiating the Initialize variable flow action. Set the parameters of the variable.

  • Name: Provide the name manually as the Date of Birth.
  • Type: Select datatype as String from the drop-down.
  • Value: Select the value as the Date of Birth variable from dynamic content.
dayOfYear from SharePoint date in Microsoft Power Automate

3. Take the dayOfYear() expression and the variable into the Compose flow action under the trigger.

Select a field -> Click Expression -> Insert below expression.

dayOfYear(variables('Date of Birth'))

Then, Click on OK.

Get day of year from SharePoint date in Power Automate

4. Save and Test the flow manually once the flow is created. Following that, add or modify an item to the associated SharePoint list. Here, I was modifying one of the existing SharePoint list items.

Power Automate Get day of year from SharePoint date

5. When the flow runs successfully, it will display the output in the compose flow action. The return value from the dayOfYear() expression will be 356, which is the 356th day of the year.

  • Here, the triggered date is 12/22/2023, the 356th day of the year.
Microsoft flow get day of year from SharePoint date

This is how to use the Power Automate dayOfYear() expression to return the day of the year from a timestamp.

Conclusion

I hope u got a better understand how to utilize the dayOfYear() function effectively in Power Automate. Through this tutorial, I have demonstrated the dayOfYear() function’s syntax in Power Automate will be expounded upon, and examples of this function will be provided, as outlined below:

  • Power Automate dayOfYear() of utcNow
  • Power Automate dayOfYear() from SharePoint Date

Additionally, you may like some more Power Automate tutorials: