A Guide to Power Automate Dates & Times

Power Automate - Solutions

This is something I’ve been asked for regularly; an illustrated guide to Power Automate Dates & Times! We will focus on the multiple ways you can retrieve, manipulate and change both dates and times.

There’s a video showing how to do this step-by-step or alternatively there is a text based walkthrough below:

Video:

do not forget to unmute

Walkthrough:

Retrieving Both Date & Time

utcNow Function Method

The utcNow() function (used in a Compose action) returns the date and time in a format such as:

As you can see that isn’t particularly pleasing for a visual representation and will more-than-likely be used if you’re specifically capturing an exact date/time point, for example, a record of an event.

Current Time Action Method

You can also retrieve the date by using the Current Time action. This, similarly to the utcNow() function retrieves the current date and time in the same format, however, it’s returned as a JSON object, as shown below:

So this is how you get both the date and time, but I’m not in UTC! How do I get my local (PST) timezone? We will look at that in the next section for both the function and the action approach.

Changing Time Zone

@utcNow Function Method

The @utcNow function can be manipulated by using an additional function, addHours(). To use this rather than simply putting “utcNow()” in the expression section, you would need to put addHours() then pass utcNow() into it as the first parameter. Then you need to pass the hour difference (for example PST is UTC – 8) separated by a comma.

To get PST timezone you would then use: addHours(utcNow(), -8). You can see the difference below:

Current Time Action Method

The Current Time method is arguably more simple. You simply pass the Current Time action result into a Convert Time Zone action. Then you select the source time as UTC (or if you’re retrieving the time from a different source you will be required to select the correct time zone).

Once that’s selected, you can simply select the ‘Destination Time’; the time zone you wish to output, i.e. PST. The difference is that you’re required to select a Format String type, even though it does not have a red star the action will fail if you leave this blank.

Date and Time Formatting with @utcNow()

The Current Time action format is, as previously shown, with the Convert Time Zone. The @utcNow() function requires some more input to format the date and time correctly.

@utcNow(‘dd’)

This will display the current day in a numerical value i.e. 01 for the 1st of the month.

@utcNow(‘dddd’)

This will display the current day in a week day name text value i.e. Monday.

@utcNow(‘MM’)

Now, you may think, the month will be ‘mm’ but you’re wrong! You need to make sure they’re capitalised! This will display the current month in a numerical value i.e. 25 for the 25th of the month.

@utcNow(‘MMMM’)

The same goes for the text value for the month, you need to capitalise the MMMM. This will display the current month in a name based text value i.e. December.

@utcNow(‘yyyy’)

Now we’re back to non-capitalisation for the year. This will provide the current year.

@utcNow(‘t’)

This provides the current time in an hours:minutes and AM/PM.

@utcNow(‘T’)

This provides the current time in an hours:minutes:seconds and AM/PM.

Day/Month/Year

Combining these functions allows you to create and change the format of a date. @utcNow(‘dd/mm/yyyy’) will providing you with a date in a numerical format such as 25/12/2019.