Guide for Power Automate

Date and Time field manipulations are very common in business applications. In Power Automate we can use a list of Data & Time related expressions to manage data time fields. In this post we will discuss all expressions about data and time field expressions.

The below is the list of data & time expressions available in Power Automate. The Date Time fields expressions use format as common parameter to understand all formats of date time refer here Standard Formats & Custom Formats.

The below examples are constructed by taking a variable “Initial Date“.

The date taken as source date is “2021-09-13T00:00:00Z” (year-month-dayThh:mm:ssZ)

ExpressionsDescription
addDaysThis function is used to add number of days to an existing timestamp. You can also use negative number to deduct days.
Syntax addDays('<timestamp>', <days>, '<format>'?)
Ex : addDays(variables(‘Initial Date’),7,’f’)
Ex : addDays(variables(‘Initial Date’),-7,’f’)
addHoursThis function is used to add number of hours to an existing timestamp. You can also use negative number to deduct hours.
Syntax addHours('<timestamp>', <hours>, '<format>'?)
Ex : addHours(variables(‘Initial Date’),5,’f’)
Ex : addHours(variables(‘Initial Date’),-5,’f’)
addMinutesThis function is used to add number of minutes to an existing timestamp. You can also use negative number to deduct minutes.
Syntax addMinutes('<timestamp>', <minutes>, '<format>'?)
Ex : addMinutes(variables(‘Initial Date’),5,’f’)
Ex : addMinutes(variables(‘Initial Date’),-5,’f’)
addSecondsThis function is used to add number of seconds to an existing timestamp. You can also use negative number to deduct seconds.
SyntaxaddSeconds('<timestamp>', <seconds>, '<format>'?)
Ex : addSeconds(variables(‘Initial Date’),6,’f’)
Ex : addSeconds (variables(‘Initial Date’),-6,’f’)
addToTimeThis function adds a number of time units to an existing timestamp. You can also use negative number to deduct timestamp.
Syntax : addToTime('<timestamp>', <interval>, '<timeUnit>', '<format>'?)
Ex: addToTime(variables(‘Initial Date’) , 1, ‘Day’)
Ex: addToTime(variables(‘Initial Date’) , -1, ‘Day’)
You can use time unit as : “Second”, “Minute”, “Hour”, “Day”, “Week”, “Month”, “Year”
convertFromUtcThis function converts an existing timestamp from Universal Time Coordinated (UTC) to the target time zone. For all Time zone codes see here.
SyntaxconvertFromUtc('<timestamp>', '<destinationTimeZone>', '<format>'?)
For example if you want to convert UTC to EST then you have to use like below.
Ex : convertFromUtc(variables(‘Initial Date’) , ‘Eastern Standard Time’,’f’)
convertTimeZoneThis function converts a timestamp from the source time zone to the target time zone.
Syntax : convertTimeZone('<timestamp>', '<sourceTimeZone>', '<destinationTimeZone>', '<format>'?)
Example : If you want to convert from India Standard Time (IST) to Eastern Standard Time (EST) then use the expression as below:
Ex:
convertToUtcThis function converts an existing timestamp to Universal Time Coordinated (UTC). For all Time zone codes see here.
SyntaxconvertToUtc('<timestamp>', '<sourceTimeZone>', '<format>'?)
For example if you want to convert IST to UTC then you have to use like below.
Ex : convertToUtc(variables(‘Initial Date’) , ‘Indian Standard Time’,’f’)
dayOfMonthThis expression return the day of the month from an existing timestamp.
SyntaxdayOfMonth('<timestamp>')
Example : This example returns the number for the day of the month from this timestamp:
dayOfMonth( variables(‘Initial Date’)) It returns this result: 13
dayOfWeekThis expression return the day of the week from an existing timestamp.
SyntaxdayOfWeek('<timestamp>')
Example : This example returns the number for the day of the week from this timestamp:
dayOfWeek(variables(‘Initial Date’)) It returns this result: 1
NOTE : The day of the week from the specified timestamp where Sunday is 0, Monday is 1, and so on
dayOfYearThis expression return the day of the year from an existing timestamp.
SyntaxdayOfYear('<timestamp>')
Example : This example returns the number for the day of the year from this timestamp:
dayOfYear(variables(‘Initial Date’)) It returns this result: 256
formatDateTimeThis expression returns the date format from a timestamp. Example to display in “yyyy-MM-dd” format then you have to pass like below:
formatDateTime(variables(‘Initial Date’),’ yyyy-MM-dd ‘)
getFutureTimeThis Return the current timestamp plus the specified time units.
getFutureTime(<interval>, <timeUnit>, <format>?)
getFutureTime(5, 'Day', 'D')
This returns the timestamp by adding 5 days to the current date.
getPastTimeThis Return the current timestamp minus the specified time units.
getPastTime(<interval>, <timeUnit>, <format>?)
getPastTime(6, 'Day', 'D')
This returns the timestamp by substracting 6 days to the current date.
startOfDayReturn the start of the day for a timestamp.
startOfDay('<timestamp>', '<format>'?)
startOfDay('2018-03-15T13:30:30Z')
this returns “2018-03-15T00:00:00.0000000Z”
startOfHourReturn the start of the hour for a timestamp.
startOfHour('<timestamp>', '<format>'?)
startOfHour('2018-03-15T13:30:30Z')
And returns this result: "2018-03-15T13:00:00.0000000Z"
startOfMonthReturn the start of the month for a timestamp.
startOfMonth('<timestamp>', '<format>'?)
startOfMonth('2018-03-15T13:30:30Z')
This example returns the start of the month in the specified format for this timestamp:
subtractFromTimeSubtract a number of time units from a timestamp.
subtractFromTime('<timestamp>', <interval>, '<timeUnit>', '<format>'?)
subtractFromTime('2018-01-02T00:00:00Z', 1, 'Day')
The unit of time to use with interval: “Second”, “Minute”, “Hour”, “Day”, “Week”, “Month”, “Year”
ticksReturn the ticks property value for a specified timestamp.
ticks('<timestamp>')
ticks(variables(‘Initial Date’))
utcNowReturn the current timestamp as a string.

Reference : https://softchief.com/2021/09/13/use-of-date-time-expressions-guide-for-power-automate-complete-tutorial/