This post will show you how to add dates to your flow and action headers.
Power automate utcNow() function
One of the most common scenarios in Power Automate is to get today's date. Depending on your use case, you might want to include the time in your output so that you have a date and time. In this situation, the utvNow() function can come in handy.
The utcNow() returns the current date and time ( DateTime value) in Coordinated Universal Time (UTC).
This syntax for this is:
formatDateTime(utcNow(), 'yyyy-MMMM')
The formatDateTime in the syntax above allows us to format date and time values into a particular format regardless of the time zones. You can learn more from the documentation.
You can make use of it in your flow by:
Creating an action for example, an Initialize variable (An action that lets you create a variable so you can declare it and use it at a global level later in your scoop)
Select the Input field, which, in our case, is Value.
Select Add dynamic content.
Select Expression.
Type in the syntax above.
Click Ok.
You can make further adjustments to this syntax, like getting your date a month back. Here is the same syntax:
formatDateTime(subtractFromTime(utcNow(), 1, 'Month'), 'yyyy-MMMM')
Power automate add days function
The Add days function is another interesting function.
The Add days add days to your timestamp. Other functions in this category are the addHours, addMinutes, and addSeconds functions, which add hours, minutes, and seconds, respectively.
formatDateTime(addDays(utcNow(),4), 'yyyy-MMMM')
Power automate date duration
Date duration is another way to display dates. To do this, you will need to use the Concat functions.
The syntax below shows a date period from today to 7 days back.
concat(formatDateTime(subtractFromTime(utcNow(), 7, 'Day'), 'yyyy MMMM dd'), ' to ', formatDateTime(utcNow(), 'yyyy MMMM dd'))
Conclusion
Once you have all these dates in variables, you can call them and use them in your flow to perform various actions, such as Send an email.