
Table of Contents
formatdatetime power automate

Introduction to formatdatetime power automate
So, you’re building automation flows and suddenly you’re stuck trying to get a date in the right format. Been there? That’s exactly where formatDateTime
in Power Automate comes to the rescue.
What is Power Automate?
Power Automate, formerly known as Microsoft Flow, is a powerful tool that lets you automate repetitive tasks. Whether it’s sending emails, organizing files, or syncing data, Power Automate can do it all—without you formatdatetime power automate writing a single line of code.
Importance of Date and Time Formatting in Automation
Date and time are everywhere. You use them in email subject lines, file names, logs, notifications—you name it. And if they’re not in the right format, things can get messy fast.
Understanding the formatDateTime Function
What is formatDateTime in Power Automate?
formatDateTime
is a built-in expression used to convert a date/time value into a readable or system-compatible string format.
Basic Syntax of formatDateTime
plaintextCopyEditformatDateTime(timestamp, format)
timestamp
: The actual datetime value.format
: A string defining how you want the output to look.
Parameters Explained
timestamp
: This can beutcNow()
or any other datetime variable.format
: Use date/time placeholders likeyyyy-MM-dd
,HH:mm:ss
, etc.
Common Use Cases
Displaying user-friendly dates in emails.
- Creating dynamic file names like
Report_2025-04-13.xlsx
. - Updating SharePoint columns with formatted timestamps.

Using formatDateTime in Real-World Scenarios
Automating Email Time Stamps
Ever wanted your email subject to include the current date? Like this:
plaintextCopyEdit"Daily Report - " & formatDateTime(utcNow(), 'MMMM dd, yyyy')
Creating Dynamic File Names
Need to avoid overwriting files? Add a timestamp: formatdatetime power automate.
plaintextCopyEdit"Invoice_" & formatDateTime(utcNow(), 'yyyyMMdd_HHmmss') & ".pdf"
Formatting Dates for SharePoint Columns
Want to update a SharePoint item with a clean date? Easy:
plaintextCopyEditformatDateTime(triggerOutputs()?['headers']['x-ms-file-last-modified'], 'yyyy-MM-dd')
formatDateTime Syntax Deep Dive
Format Strings Explained
Let’s break it down:
Year (yyyy
), Month (MM
), Day (dd
)
yyyy
– 2025MM
– 04dd
– 13
Hour (HH
), Minute (mm
), Second (ss
)
HH
– 24-hour formatmm
– minutesss
– seconds
Timezone Adjustments
Power Automate runs on UTC, so if you’re not in UTC, use:
plaintextCopyEditconvertTimeZone(utcNow(), 'UTC', 'Pacific Standard Time')
formatDateTime Expressions and Examples
Getting Current Date and Time
plaintextCopyEditformatDateTime(utcNow(), 'yyyy-MM-dd HH:mm:ss')
Customizing Output Formats
Want it fancy?
plaintextCopyEditformatDateTime(utcNow(), 'dddd, MMMM dd yyyy, hh:mm tt')
Result:
plaintextCopyEditSunday, April 13 2025, 04:15 PM
Combining with Other Expressions
plaintextCopyEditformatDateTime(addDays(utcNow(), 7), 'yyyy-MM-dd')
That gives you a date exactly a week from now.

Practical Examples for Business Automation
Invoice Generation Dates
plaintextCopyEdit"Invoice Date: " & formatDateTime(triggerOutputs()?['headers']['x-ms-received'], 'dd/MM/yyyy')
Deadline Reminders
plaintextCopyEditformatDateTime(addDays(utcNow(), 3), 'dddd, MMM dd')
Weekly Reports
plaintextCopyEdit"Weekly Report - Week of " & formatDateTime(utcNow(), 'MMMM dd, yyyy')
Common Mistakes and How to Avoid Them
Invalid Format Strings
Using mm
instead of MM
? That’ll give you minutes instead of month.
Wrong Data Types
Passing a string instead of a datetime value? Boom—error.
Timezone Confusions
Always remember: Power Automate defaults to UTC.
Advanced Tips and Tricks
Conditional Date Formatting
plaintextCopyEditif(equals(dayOfWeek(utcNow()), 0), 'Weekend', 'Weekday')
Using formatDateTime in Loops
In Apply to each
, use:
plaintextCopyEditformatDateTime(items('Apply_to_each')?['Created'], 'MM/dd/yyyy')
Nesting formatDateTime in Other Functions
plaintextCopyEditconcat('Report_', formatDateTime(utcNow(), 'yyyyMMdd'), '.csv')

formatDateTime vs Other Date Functions
toDateTime()
Converts string to datetime.
convertTimeZone()
Changes timezone of datetime.
addDays(), addHours(), subtractDays()
Manipulate date values for custom logic.
Best Practices When Using formatDateTime
Naming Conventions
Use clear variable names like formattedInvoiceDate
.
Consistency in Formatting
Stick to a standard like yyyy-MM-dd
across all flows.
Documentation and Maintainability
Add comments to explain why you’re using a certain format.
Troubleshooting formatDateTime Issues
Debugging Errors
Use Compose
actions to test your expressions.
Handling Null or Empty Values
Use coalesce()
to avoid null errors:
plaintextCopyEditformatDateTime(coalesce(triggerBody()?['startDate'], utcNow()), 'MM/dd/yyyy')
Logging and Monitoring
Log the output to email, Teams, or a SharePoint list.

Working with Different Locales
Date and Time Localization
formatDateTime
doesn’t auto-localize. Combine with convertTimeZone()
for accurate output.
Regional Settings in Power Automate
Make sure your environment’s regional settings align with your desired format.
Integrating formatDateTime with Other Connectors
Outlook
Add dates to subject lines or email bodies.
SharePoint
Update list items with human-readable dates. formatdatetime power automate.
Excel Online
Populate columns with formatted timestamps.
formatdatetime power automate
Pros and Cons
- Expressions: More flexible, customizable.
- Dynamic Content: Easier to use but limited.
When to Use Which
Use dynamic content for simple needs; expressions for advanced formatting.

formatdatetime power automate
If you’re working with Power Automate, learning how to use formatDateTime
is non-negotiable. It brings clarity, consistency, and control to your workflows. From email automations to system logs, it’s a small tool that makes a big difference.
Master it, and your flows will look more professional and work more reliably—guaranteed.
FAQs
1. What is the difference between utcNow() and formatDateTime()?utcNow()
returns the current datetime in UTC. formatDateTime()
formats that value into a readable string.
2. How do I get the current time in a specific timezone?
Use convertTimeZone(utcNow(), 'UTC', 'Eastern Standard Time')
.
3. Can I use formatDateTime inside a switch or condition?
Yes, it works perfectly in expressions within conditions or switch statements.
4. What happens if the date value is null?
It will throw an error. Use coalesce()
to provide a fallback.
5. Is it possible to combine formatDateTime with variables?
Absolutely. You can pass any datetime variable to formatDateTime
.
Leave a Reply