Power Automate startOfMonth() Function

Are you looking for how to use the startOfMonth() function in Power Automate? Then, check out this blog post on Power Automate’s date and time function.

This Power Automate tutorial will introduce the Power Automate startOfMonth() function’s functionality and syntax. In addition to this, I will explain the examples of the startOfMonth() function inside a Power Automate.

Power Automate startOfMonth() function retrieves the exact start time of a month, including starting on the first day of the month with hours, minutes, and seconds beginning with zero as time units.

Power Automate startOfMonth() Function

The Power Automate startOfMonth() function will be utilized to obtain the initial date of a month or a provided timestamp.

The return output from the startOfMonth() function will be timestamp specified, which is a string type, starting on the first day of the month at the zero-hour mark.

Let’s consider the timestamp as “27-12-2023“. I wanted to get the start of the month on this particular date. Then, my result will be 2023-12-01T00:00:00.0000000Z.

Power Automate startOfMonth() expression

This is a brief description of the Power Automate startOfMonth() function.

Power Automate startOfMonth() Syntax

Now, I will show you how the Power Automate syntax for the startOfMonth() format looks like:

startOfMonth('timestamp', 'format')

Parameters:

  1. Timestamp: It works with only one parameter required to be a String and mandatory to provide.
  2. Format: It is an optional field where a user can give a specified format for date and time. If the format is not given, it will take the default format. The default format for the timestamp is (yyyy-MM-ddTHH:mm: ss.fffffffK).

Example:

startOfMonth('2023-12-26')
  • 2023-12-26= Provide a specific timestamp or a date.

This function returns the output as “2023-12-01T00:00:00.0000000Z“.

This is the syntax format for utilizing the Power Automate startOfMonth() function.

Power Automate startOfMonth() of utcNow

Let’s begin with how to get the Power Automate start of the month for a current date and time in a flow.

Example:

Suppose Today’s date is December 26th, 2023, and we want to retrieve the start of the current month. In that case, the output should be “2023-12-01T00:00:00.0000000Z“.

Power Automate startOfMonth() Function

Go through the below-given steps.

1. Navigate 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.

  • Inside the trigger -> Select the input to Trigger Date.
startOfMonth() Function in Power Automate

2. To initialize the string variable and assign it the value of utcNow() with startOfMonth() expression, add an Initialize variable flow action.

Configure the variable properties as follows:

  • Name: Set the name manually as the Date.
  • Type: Select the variable type as a String from the drop-down menu.
  • Value: Select a field -> Click Expression -> Insert below expression.
startOfMonth(utcNow())

After that, Click OK.

Get startOfMonth() Function in Power Automate

3. Include a Compose flow action to take the value generated from the initialized variable.

  • Inputs: Select the field -> Choose a utcNow variable from the dynamic content.
Power Automate startOfMonth() of utcNow

4. Now it’s time to Save and Test the flow. Run the flow manually.

5. When the flow is successful, the composed output will get a start month of the current date, as displayed in the screenshot below.

  • The result of the Power Automate startOfMonth() expression will be 2023-12-01T00:00:00.0000000Z.
startOfMonth() of utcNow Power Automate expression

This is how to utilize the startOfMonth() for a current date and time in a Power Automate.

Power Automate startOfMonth() of Date Variable

In this section, I will explain how to get the start of the month for a particular date variable.

Example:

Suppose we have a timestamp or a particular date “30-12-2023“. In that case, we can extract the start month of this timestamp, which would be “2023-12-01T00:00:00“.

Power Automate startOfMonth() of Date Variable

To achieve this example, follow the below steps:

1. Take an Initialize Variable flow action to initialize the triggered date that will trigger during the flow.

Set the parameters of an initialize variable:

  • Name: Provide the name manually as the Date.
  • Type: Select the variable type as a String from the drop-down menu.
  • Value: Select the field -> Select Expression -> Give the code below.
startOfMonth(utcNow(),'yyyy-MM-ddTHH:mm:ss')

Then, Click OK.

Power Automate get StartOfMonth() for date

2. Upon saving the flow, choose the desired date to trigger in the Run flow window. Afterward, proceed to select “Run flow.”

  • The Triggered date = 2023-12-30.
How to get startOfMonth() for a date variable in Power Automate

3. When the Power Automate flow runs successfully, open the compose outputs to display the provided timestamp in the startOfMonth(), as shown below.

  • The output result will be 2023-12-01T00:00:00.
Get Power Automate startOfMonth() for a date variable

This is how to get the start of a month of a date variable in a Power Automate using the startOfMonth() function.

Power Automate startOfMonth() of SharePoint Date

In this section, I will demonstrate an example of how to get startOfMonth() for a SharePoint date using Power Automate.

Example:

I have taken a SharePoint list named [Task List] with a date column as Task Deadline. This list has various items along with dates, as shown below:

Power Automate startOfMonth() of SharePoint Date

My requirement is to extract the month’s start time from the SharePoint date column named “Task Deadline” using Power Automate. For instance, if we take the date “30/12/2023,” the result will be 01/12/2023T00:00:00.

Power Automate Get startOfMonth() for a SharePoint date

To work around this, 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.
Use Power Automate startOfMonth() function

2. To initialize the Task Deadline column, add the Initialize variable flow action, ensuring to set the variable parameters accordingly.

  • Name: Set the name for the SharePoint date column accordingly.
  • Type: Select the variable type as String.
  • Value: Select the field -> TakeTask Deadline from the dynamic content of the SharePoint list.
Power Automate startOfMonth() function format

3. Add the expression startOfMonth() and the value from the initialized variable into the Compose flow action and configure it with the following details.

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

startOfMonth(variables('Task Deadline'),'dd/MM/yyyyTHH:mm:ss')

After the expression, Click OK.

Power Automate startOfMonth() of SharePoint Date

4. After that, save and run the flow manually. At this point, create or modify an item in the SharePoint list.

Use Power Automate startOfMonth() expression

5. When the Power Automate flow execution is successful, The compose flow action returns startOfMonth() expression’s return value will follow the format  01/12/2023T00:00:00.

Power Automate startOfMonth() for a SharePoint date

This is how to get the start of the month for a SharePoint list date column using the Power Automate startOfMonth() function.

Conclusion

I hope this tutorial has given you a comprehensive understanding of effectively utilizing Power Automate’s startOfMonth() function.

Moving forward, I have covered the function’s syntax and provided several examples of its implementation in Power Automate.

Also, you may like some more Power Automate function tutorials: