Power Automate Date Functions [10+ Examples]

We can use Power Automate Date functions in a Power Automate flow to manipulate the date and time in the datasource or in the SharePoint list.

In this tutorial, I will list out and explain all the Power Automate date and time functions, including:

  • Power Automate addDays() Function
  • Power Automate addhours
  • Power Automate addminutes
  • addSeconds Power Automate
  • getPastTime Power Automate
  • getfuturetime Power Automate
  • Get current date in Power Automate
  • Power Automate format date dd/mm/yyyy
  • Power Automate utcnow format yyyymmddhhmmss
  • formatDateTime Power Automate
  • Power Automate utcnow
  • dayofyear Power Automate
  • Power Automate dayOfWeek
  • dayofMonth in Power Automate
  • Power Automate startofday, startofhour and startofmonth
  • addToTime and Subtract from time in Power Automate
  • convertfromutc and converttoutc Power Automate
  • Power Automate convertTimeZone() expression
  • Power Automate dateDifference

Power Automate Date Expressions

To access the date and time information, follow through the below-mentioned topics:

Power Automate addDays() Function

To add the days to a specific date, check out the below steps:

addDays() Function: Power Automate addDays() expression helps to add a given number of days to a particular date.

addDays('timestamp', days, 'format')

Example:

Suppose Today’s date is 11-04-2024. I wanted to add 10 days to this specific date. Then, My result will be 21-04-2024.

1. Create an ‘Instant cloud flow’ in Power Automate.

Instructions to follow: Navigate to https://make.powerautomate.com to open the Power Automate Home page -> Click +Create -> Select ‘Instant cloud flow’ -> In the next window, Provide a flow name & select trigger ‘Manullay trigger a flow’ -> Tap Create button.

2. Take out the Initialize Variable flow action and set the details of the variable like Name, Type, and Value.

addDays(utcNow(),10,'dd-MM-yyyy')
Power Automate date functions

3. Now, select the Compose flow action and take the initialize variables value in the Inputs section.

Date in Power Automate

4. Onec the flow is ready, save and test the flow.

5. When the flow runs successfully, open the ‘Compose’ flow action to check the output from the addDays() expression.

Power Automate Date

Similarly, the below-mentioned Power Automate functions will also work exactly as the addDays() function.

FunctionDescriptionSyntax
addHoursIt will add a specified number of hours to a date or timestamp. addHours(‘timestamp’, hours, ‘format’)
addMinutesAs the above function, It will add provided minutes to a date or given timestamp.addMinutes(‘timestamp’, Minutes, ‘format’)
addSecondsThis function adds a number of seconds to a particular date and time.addSeconds(‘timestamp’, seconds, ‘format’)

getPastTime Power Automate

To get the past time from a specific time stamp, look out the below steps:

See also  Power BI Date Hierarchy - Complete tutorial

getPastTime() Function: This function will subtract different time units from a current time stamp, such as seconds, minutes, hours, days, weeks, months, or years, as needed.

Syntax: getPastTime('interval', 'timeunit', 'format')

Example:

Let’s assume the current date is 11-04-2024. I wanted to subtract 2 weeks from Today’s date. So, the return output will be like ”August 18, 2023,”.

Follow the steps mentioned in the above example:

1. Take Week as a time unit in the getPastTime() expression so that it will subtract given intervals of weeks from the current timestamp in the compose flow action.

getPastTime(2,'Week','MMMM dd, yyyy')
Power Automate getpasttime

Output:

The below image represents the past time in a Power Automate flow.

getpasttime Power Automate

Power Automate has one more function that resembles the getPastTime() function, as is mentioned in the table below:

FunctionDescriptionSyntax
getFutureTime()This function adds specific time units to the current timestamp, such as seconds, minutes, hours, days, weeks, months, or years, based on unique needs.getFutureTime(‘interval’, ‘timeunit’, ‘format’)

Power Automate Get Current Date

To get the current date along with the time, follow the below example:

utcNow() Function: This Power Automate function will return the current timestamp. Also, we can specify the format of the date and time.

Syntax: utcNow('<format>')

Example:

1. In a manual trigger flow, select Compose to provide the expression to get the current date.

utcNow('dd-MM-yyyy')

Note:

To get the utcnow format in yyyymmddhhmmss using Power Automate, you can use the expression like utcNow(‘yyyymmddhhmmss’).
Power Automate today's date

Output:

You can see the below image with the current date in a dd-MM-yyyy format.

Power Automate get current date

Power Automate formatDateTime Examples

To customize the date and time in different formats, go through the below examples:

formatDateTime() Function: This Power Automate formatDateTime() function is used to return the timestamp in a specific desired format.

formatDateTime('timestamp', 'format')

Example: dd-MM-yyyy

1. In the Compose flow action, provide the below-given expression.

formatDateTime(utcNow(),'dd-MM-yyyy')
Power Automate formatdatetime examples

Output:

Power Automate format date dd-mm-yyyy

List of formats that a Timestamp can be formatted:

Year-Month-Date Format – formatDateTime(utcNow(),’yyyy-MM-dd’)
Date with Time – formatDateTime(utcNow(),’yyyy-MM-ddTHH:mm:ss’)
Day of the week, Month day, Year Format – formatDateTime(utcNow(),’dddd,MMMM dd,yyyy’)
Date in 12 Hours Time – formatDateTime(triggerBody()[‘date’],’MM/dd/yyyy hh:mm tt’)
Date in in 24 Hours Time – formatDateTime(triggerBody()[‘date’],’dd/MM/yyyy HH:mm:ss tt’)

dayofyear Power Automate

To get the particular day of year using Power Automate date functions, follow the steps:

See also  How to get selected value from Slicer in Power BI

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.

Syntax: dayOfYear(‘timestamp’)

Example:

1. To know the day of the year for a utcNow(), please follow the instructions below:

  • Choose the “Manually trigger” flow.
  • Set the expression as utcNow() with the dayOfYear expression in the Compose action.

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

dayOfYear(utcNow())
Power Automate date format

Output:

  • The result from the expression will be the 103 days of that particular year. And Today’s date is 12-04-2024.
Power Automate date and time function
FunctionDescriptionSyntax
dayOfWeek() FunctionIt will return an integer representing the day of the week for the provided timestamp, where Sunday is 0, Monday is 1, and so on Saturday is 6.It will return an integer representing the day of the week for the provided timestamp, where Sunday is 0, Monday is 1, and Saturday is 6.
dayOfMonth()Power Automate dayOfMonth() function returns the day of a month from a given timestamp. dayOfMonth(‘timestamp’)

Power Automate startOfDay() Expression

To retrieve the start of day from a given timestamp, follow the example given below:

startOfDay() Function: This function allows you to get the beginning of a day or a timestamp with all hours, minutes, and seconds beginning with zero as time units.

Syntax: startOfDay('timestamp', 'format')

Example:

Let’s assume a specific date is “2024-04-20, ” and I need to get the current day’s start day. The result will be 2024-04-20T00:00:00.0000000Z.

1. Inside the Compose flow action, take the expression provided in the below code.

startOfDay(triggerBody()?['date'])
startofday Power Automate

Output:

The result from the Power Automate start-of-day function will retrieve hours, minutes, seconds, and fractions of seconds, as shown in the figure below:

Power Automate create date

Similar Functions:

FunctionDescriptionSyntax
startOfHour()Power Automate startOfHour() function retrieves the initial time of an hour, including minute and seconds.startOfHour(‘timestamp’, ‘format’)
startOfMonth()This function will retrieve the first day of a month with zero time units,startOfMonth(‘timestamp’, ‘format’)

addToTime() Power Automate

To add the particular unit of time to date using Power Automate, check out this example.

Power Automate addToTime(): This function is useful to add a timestamp plus the specified number of time units like Second, Minute, Hour, Day, Week, Month, and Year.

Syntax: addToTime('timestamp', interval, 'timeUnit', 'format')

Example:

See also  Power Automate error: The property '__metadata' does not exist on type 'SP.List'

Suppose we take a specific date, “2024-05-01,” and add two days; the resulting timestamp will be “2024-05-03.”

1. To provide the expression of addToTime(), take the Compose action. Place the code below in the inputs section.

addToTime(triggerBody()?['date'],2,'Day')
Power Automate addtotime

Result:

Triggered Date: 2024-05-01.

Check the output so that it will add the time units according to the given expression.

Power Automate adddays

Similar Power Automate Date Function:

FunctionDescriptionSyntax
subtractFromTime() ExpressionPower Automate subtract from time function subtract various time units, including seconds, minutes, hours, days, weeks, months, or years, based on the requirements.subtractFromTime(‘timestamp’, interval, ‘time unit’, ‘format’)

Power Automate convertFromUtc()

To convert the Universal coordinated timezone to the destination time zone, see the example below:

convertFromUtc(): This function is helpful in converting the coordinated universal timezone to the destination timezone with the desired format.

convertFromUtc('timestamp', 'destinationTimeZone', 'format')

Example:

Now, Universal Coordinated Time is converted into the India standard timezone. UTC value is 2024-04-12T06:03:56.8584728Z.

1. Add the Initialize variable flow action, set the Name, Type and take Value as utcNow().

Power Automate convertfromutc

2. Place the below given expression inside the compose, to convert the timezone to desired timezone.

convertFromUtc(utcNow(),'Pacific Standard Time','dd-MM-yyyy hh:mm tt')
Convertfromutc Power Automate

Output:

Here, you can check the output that will converted into the specific timezone.

Power Automate time format

Power Automate Similar Date Function:

FunctionDescriptionSyntax

convertToUtc()
This function converts a timestamp from the source time zone to Universal Time Coordinated (UTC).convertToUtc(‘timestamp’, ‘sourceTimeZone’, ‘<format’?)

convertTimeZone Power Automate

To convert the different time zones of the world, you can use the Power Automate convertTimeZone() function. Check the example given below:

convertTimeZone(): This function is helpful to convert a timestamp from the source time zone to the target time zone.

syntax: convertTimeZone('timestamp', 'sourceTimeZone', 'destinationTimeZone', 'format')

Example:

Let’s take a particular date as a source time, and now I want to convert it to a destination timezone like Eastern Standard Time.

1. Select the Compose action, given the expression in the Inputs parameter.

convertTimeZone(triggerBody()?['date'],'India Standrad Time','Pacific Standard Time','dd-MM-yyyy')
formatdatetime(utcnow() 'yyyy-mm-dd') timezone

Result:

In the screenshot represented below, you can see the timezone has been for the provided timestamp.

Power Automate converttimezone

dateDifference Power Automate

To know the difference between the two dates, go through the below points.

dateDifference(): The Power Automate dateDifference() function will calculate the time difference between two timestamps by subtracting the start date from the end date.

It will extract the difference in formats like Days, Hours, Minutes, and Seconds.

Syntax: dateDifference('startDate','endDate')

Output of dateDifference Format: days. hours: minutes: seconds

Example:

Here, I wanted to calculate the difference between the two dates. Then, the result will be like

1. In the Manual trigger flow, take two date inputs for the start date and end date.

2. In this step, add a Compose flow action to express dateDifference() in the Inputs section.

Inputs: dateDifference(triggerBody()['date'],variables('End date'))
parsedatetime Power Automate

Save and run the flow.

In the Test flow window, select Start Date and End Date. Click Runflow.

Power Automate dateDifference

Output:

You can see the output from the Power Automate dateDifference() function in the image below:

datedifference Power Automate

This is all about Power Automate date function introduction and its examples.

Moreover, you may like:

Conclusion

I trust this Power Automate tutorial guide has provided complete information on all the date and time functions and how to manipulate the dates with various examples like:

  • How to use Power Automate date
  • What is getpasttime in Power Automate
  • getfuturetime power automate
  • Power Automate get current date
  • Power Automate date format yyyymmdd
  • thank you very much for the “get from SPL, check for empty, format if not null” tip.

    This issue was driving me crazy in a “add/update Excel from SPL” Flow. Without formating: Flow runs fine. With: all of a sudden it complained that “date field is null”.

    Still got the problem that somehow, SPL or aAutomate mix up some of the dates – resulting in MM/dd/yyyy instead of dd/MM/yyyy.
    Which is very confusing, since all other dates are sent correct.

  • >