Overview of Date and Time Functions in Power Automate

Overview of Date and Time Functions in Power Automate

🧭 Overview of Date and Time Functions in Power Automate

Power Automate provides many built-in Date and Time expressions using PowerFx-style functions (based on Azure Logic Apps workflow definition language).

All DateTime expressions begin with formatDateTime(), addDays(), utcNow(), etc., and are used in dynamic content or expressions inside flows.


📅 Commonly Used Date and Time Functions

1. utcNow()

Returns the current date and time in UTC.

  • Syntax: utcNow()
  • Example Output: 2025-07-22T08:12:34Z

✅ Use this when you need the current time in flows.


2. addDays()

Adds a number of days to a specified date.

  • Syntax: addDays(startDate, numberOfDays, format?)
  • Example:

addDays(utcNow(), 5, ‘yyyy-MM-dd’)

Output: 2025-07-27


3. addHours()

Adds hours to a given date.

  • Syntax: addHours(startDate, numberOfHours, format?)
  • Example:

addHours(utcNow(), 3)

Output: 2025-07-22T11:12:34Z


4. addMinutes()

Adds minutes to a given date.

  • Syntax: addMinutes(startDate, numberOfMinutes)
  • Example:

addMinutes(utcNow(), 15)


5. subtractDays(), subtractHours(), subtractMinutes()

Subtract time from a date.

  • Example:

subtractDays(utcNow(), 7, ‘yyyy-MM-dd’)


6. formatDateTime()

Formats a given date/time into a string format.

  • Syntax: formatDateTime(date, format)
  • Examples:

formatDateTime(utcNow(), ‘yyyy-MM-dd’)

formatDateTime(utcNow(), ‘dd/MM/yyyy hh:mm tt’)

formatDateTime(utcNow(), ‘dddd, MMMM dd yyyy’)

Outputs:

  • 2025-07-22
  • 22/07/2025 02:12 PM
  • Tuesday, July 22 2025

7. convertTimeZone()

Converts a time from one time zone to another.

  • Syntax: convertTimeZone(timestamp, sourceTimeZone, destinationTimeZone, format)
  • Example:

convertTimeZone(utcNow(), ‘UTC’, ‘India Standard Time’, ‘yyyy-MM-dd hh:mm tt’)

Output: 2025-07-22 01:42 PM


8. day(), month(), year()

Extracts components of a date.

  • Examples:

day(utcNow())     ➜ 22

month(utcNow())   ➜ 7

year(utcNow())    ➜ 2025


9. dayOfWeek()

Returns the day of the week (0 for Sunday, 6 for Saturday).

  • Syntax: dayOfWeek(date)
  • Example:

dayOfWeek(utcNow()) ➜ 2  (Tuesday)


10. ticks()

Returns a long number representing date and time (used for unique ID generation).

  • Syntax: ticks(utcNow())

11. addToTime()

Adds time duration to a date.

  • Syntax: addToTime(date, interval, timeUnit)
  • Example:

addToTime(utcNow(), 30, ‘Minute’)


12. startOfDay(), startOfMonth()

Returns beginning of a day or month.

  • Examples:

startOfDay(utcNow())

startOfMonth(utcNow())


13. endOfDay(), endOfMonth()

Returns end of a day or month.

  • Examples:

endOfDay(utcNow())

endOfMonth(utcNow())


14. parseDateTime()

Parses a string into a datetime object.

  • Syntax: parseDateTime(’22/07/2025′, ‘dd/MM/yyyy’)

🛠 Real-life Examples

📌 Get current date in local time zone

convertTimeZone(utcNow(), ‘UTC’, ‘India Standard Time’, ‘yyyy-MM-dd’)


📌 Add 10 business days to a date (excluding weekends) – Use loop

Loop through days and skip weekends using dayOfWeek() logic.


📌 Format due date 7 days from now

formatDateTime(addDays(utcNow(), 7), ‘dd-MM-yyyy’)


📌 Create a timestamp for unique filename

concat(‘Invoice_’, formatDateTime(utcNow(), ‘yyyyMMdd_HHmmss’), ‘.pdf’)


📌 Calculate age from Date of Birth

div(sub(ticks(utcNow()), ticks(triggerOutputs()?[‘body/DOB’])), 3155695200000000)


📚 Formatting Reference (Standard Patterns)

Format TokenDescriptionExample
yyyyYear2025
MMMonth (01–12)07
ddDay (01–31)22
HHHour (00–23)14
hhHour (01–12)02
mmMinute (00–59)43
ttAM/PMPM
ddddDay nameTuesday

✅ Best Practices

  • Always use convertTimeZone() to adjust to local time zones.
  • For business processes, use startOfDay() and endOfDay() to reduce ambiguity.
  • Format dates before saving to Excel or SharePoint.
  • When comparing dates, always convert both to the same format and time zone.

Leave a Reply