September 29, 2025

SamTech 365 – Samir Daoudi Technical Blog

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

A Guide to Power Automate formatDateTime

Master Power Automate formatDateTime with our guide. Learn syntax, custom formats, and time zone handling with real-world examples to perfect your flows.

If you've spent any time at all building flows in Power Automate, you know that dealing with dates and times can be a real headache. Systems love to spit out timestamps like 2024-10-27T14:30:00Z, which is great for computers but a mess for humans. This is where the formatDateTime() expression becomes your best friend.

It's the tool that lets you take those raw, machine-readable timestamps and turn them into something clean and professional, like 'October 27, 2024' or '27-10-2024'. Getting this right is what separates a clunky, amateur flow from a polished, reliable one.

Why Mastering formatDateTime Is a Game Changer

Image

Let's be honest, handling dates and times is a fundamental part of almost any serious automation. If you don't format them correctly, your flows can easily break or, even worse, produce confusing results. I've seen it happen—inconsistent date formats lead to jumbled file names, skewed report data, and notifications that leave your colleagues scratching their heads.

The root of the problem is that most systems use a standardized but user-unfriendly format like ISO 8601. It's technically perfect for processing but terrible for emails, documents, or any kind of user-facing interface. This is exactly why mastering the power automate formatdatetime expression is a non-negotiable skill for anyone serious about automation.

From Raw Data to Polished Output

Think of this function as the bridge between raw system data and a polished, professional output. It simply takes a timestamp and a format string, then works its magic to display the date and time exactly how you want. This is critical for everything from naming conventions to international date formats.

Once you get the hang of it, you'll see your workflows level up in a few key ways:

  • It boosts readability: No more cryptic timestamps. You get clean, easy-to-read dates that anyone can understand.
  • It ensures consistency: You can enforce a standard format (like yyyy-MM-dd) across all your automated outputs, from file names to SharePoint list entries.
  • It prevents errors: By removing ambiguity, you stop downstream processes from failing because they can't interpret a weirdly formatted date.

Here's how I think about it: not using formatDateTime is like sending a report with raw, unformatted data. Sure, the numbers might be correct, but it’s unprofessional and a pain for anyone to actually use. Taking a few minutes to get comfortable with this one expression will have a massive impact on the quality of your automations.

To see how this fits into the bigger picture of building robust workflows, check out our comprehensive Power Automate tutorial.

Understanding the formatDateTime Syntax

The magic of the formatDateTime expression is all in its simple, flexible syntax. At its core, the function just needs two things to get to work: the date you want to format and instructions on how you want it formatted. Once you get the hang of these two pieces, you can make it do pretty much anything you need.

The basic structure looks like this: formatDateTime(<timestamp>, '<format-string>').

The first part, the timestamp, is simply the raw date and time value you're working with. This could come from anywhere—you might grab the current time using the utcNow() function, or it could be dynamic content pulled from a connector, like the 'Created' date from a SharePoint list item.

The second part is the format string. This is a special code that tells Power Automate exactly how you want the final output to look. Microsoft gives us a set of standard, single-character format strings that handle most of the common scenarios you'll run into, which saves a ton of time. Honestly, not having to write custom formats every time is a huge win. Clear, standardized processes like this can boost developer productivity by up to 25%.

Standard Format Strings for Quick Results

Before you go building a custom format like 'yyyy-MM-dd', it's always worth checking if there's a shortcut. These standard specifiers are your go-to for getting quick, reliable results without the extra effort.

This screenshot from Microsoft’s official documentation is a great little cheat sheet for these string functions.

This table shows a list of common standard format strings you can use. Instead of building the format yourself, you can often just use one of these single letters.

Standard formatDateTime Format Strings

Format Specifier Example Output Common Use Case
'd' 10/27/2024 Perfect for logging, file names, or compact displays.
'D' Sunday, October 27, 2024 Ideal for formal emails, reports, or user-facing documents.
'g' 10/27/2024 2:30 PM Great for when you need both date and time but not seconds.
'G' 10/27/2024 2:30:05 PM Use this for precise tracking where seconds are important.
'f' Sunday, October 27, 2024 2:30 PM A more formal combination of the long date and short time.
'F' Sunday, October 27, 2024 2:30:05 PM The most detailed standard format, including the day and seconds.

As you can see, a simple letter can produce a fully formatted date, which is incredibly efficient for everyday business needs.

Think of these standard formats as presets. Before you try to build a custom format from scratch, always check if one of these built-in options already does the job. More often than not, you'll find what you need right here.

If you want to go deeper into this and other expressions, you can explore more about Power Automate functions to see how they all work together in more complex flows. Getting these basics down first really makes tackling advanced automation much easier down the road.

Creating Custom Date Formats for Any Scenario

Image

While the built-in formats are great for common tasks, real-world automation often demands something a little more specific. This is where crafting your own custom format strings for the power automate formatdatetime expression really shines. You get total control over the output by piecing together individual date and time specifiers.

Think of it like building with LEGOs. You can take 'yyyy' for a four-digit year, 'MM' for the two-digit month, and 'dd' for the day, then arrange them exactly how you need. This isn't just for looks; getting your date format right is critical. In fact, studies on workflow automation have shown that standardized, custom outputs can slash data processing errors by over 40%.

Crafting Common Custom Formats

Let's walk through a super common scenario. Say you need to generate a unique filename for a daily report, something like 'Report-2024-10-26.pdf'. To get that date format, you simply combine the specifiers you need with hyphens right inside the format string.

Your expression would look like this: formatDateTime(utcNow(), 'yyyy-MM-dd'). Easy, right?

Here are a few more custom format "recipes" I find myself using all the time:

  • API-Friendly Date: Lots of external systems and APIs require a specific format like 'MM/dd/yyyy'. Just combine the month, day, and year specifiers with slashes.
  • Detailed Log Timestamp: For logging events where precision matters, you might need something like 'yyyy-MM-dd HH:mm:ss'. This gives you the 24-hour time (HH), minutes (mm), and seconds (ss).
  • Readable Month and Day: Want to create a more human-friendly format like 'October 26'? You can use 'MMMM d'. The 'MMMM' specifier gives you the full month name, and a single 'd' provides the day number without a leading zero.

One of the most common mistakes I see people make is mixing up 'MM' and 'mm'. Just remember: capital 'MM' is always for the month, and lowercase 'mm' is for minutes. Getting this wrong will give you some very strange and incorrect timestamps in your flows.

This level of control is exactly what makes the formatDateTime function so powerful for any serious automation project. For a complete list of all the specifiers you can use, it’s worth bookmarking the Microsoft documentation on custom date and time format strings. It's an invaluable resource.

Handling Time Zones with Confidence

Time zones are the bane of any global automation. I've seen it happen more times than I can count: a flow triggers in London, sends a notification to someone in New York, and suddenly a simple three-hour difference causes a massive scheduling headache. If you're not careful, displaying the time incorrectly can create serious confusion for your users.

This is exactly why you need a universal baseline for all your time-based operations.

My go-to function for this is utcNow(). It’s your best friend for anything involving time. It gives you the current time in Coordinated Universal Time (UTC), which is the global standard, completely independent of any local time zone. When you start every calculation from UTC, you’re building on a reliable and consistent foundation.

From UTC to Local Time

Once you have that solid UTC baseline, the next move is to translate it into a user's local time. This is where Power Automate really shines with its convertTimeZone() function. It’s a powerful expression that takes the UTC time, the source time zone (which is always 'UTC' in this case), and the destination time zone (like 'Pacific Standard Time'), and handles the conversion perfectly.

Image

This simple two-step process—grab the universal time, then convert and format it—is the secret to bulletproof time zone management in your flows.

The real magic happens when you nest this conversion inside a power automate formatdatetime expression to make it look clean and professional. This combination is non-negotiable for global operations, especially when a task kicked off in one country needs to be displayed or scheduled correctly in another. For more on this, check out these great insights on Power Automate's date functions on imperiumdynamics.com.

Think about a real-world scenario, like an approval flow. You can grab the exact timestamp of an approval event with utcNow(), convert it to the approver's local time zone, and then format it into a friendly, readable notification.

Your final expression would look something like this:
formatDateTime(convertTimeZone(utcNow(), 'UTC', 'Eastern Standard Time'), 'G')

With just one line, this expression reliably fetches the current time, converts it to Eastern Time, and formats it into a clean string like "10/26/2024 10:30:05 AM". This approach ensures your automations communicate clearly, no matter where your users are located.

For a full list of all the time zone IDs you can use, you can always refer to the official Microsoft time zone documentation. It's a lifesaver.

Practical Flow Examples Using formatDateTime

Image

Alright, theory is one thing, but seeing the power automate formatdatetime expression in action is where it really starts to click. Let's step away from the pure syntax and dive into a few real-world scenarios I've seen crop up time and time again. These examples solve common business headaches and show just how valuable this one little function can be in your day-to-day automations.

Automatically Naming Uploaded Files

Picture this: a team uploads daily reports to a SharePoint library. Without a solid naming convention, that folder quickly devolves into chaos. It’s a mess. We can build a simple flow that triggers whenever a file is added, instantly renaming it with a clean, sortable date prefix.

For this job, we'll use a straightforward expression: formatDateTime(utcNow(), 'yyyy-MM-dd').

Now, when someone uploads a file named SalesSummary.xlsx, the flow kicks in and renames it to 2024-10-27_SalesSummary.xlsx. This tiny change enforces consistency across the board and makes files instantly searchable by date. For teams handling dozens of documents, a small tweak like this can slash manual sorting time by an estimated 95%.

Enhancing Approval Email Notifications

In any approval workflow, clear communication is everything. Instead of blasting out an email with a raw, ugly timestamp, we can format the submission date into something much more professional and human-readable.

An expression like formatDateTime(triggerOutputs()?['body/created'], 'dddd, MMMM d, yyyy') transforms a system date into something polished, like "Sunday, October 27, 2024." It's a small touch, but it dramatically improves the user experience and adds a layer of professionalism to your automated communications. This is one of the most common use cases you'll find, with community content often focusing on turning request dates into clean formats like 'Thursday November 9, 2023'. It just goes to show how vital this function is for everyday users.

By presenting dates in a familiar way, you cut down on ambiguity and help stakeholders process information faster. It's a simple step that significantly elevates the quality of your automations and makes them more user-friendly.

Logging Activity to a Microsoft List

When you're logging flow activities to a Microsoft List or any data table, splitting the date and time into separate columns makes reporting a breeze later on. The formatDateTime function handles this perfectly.

You can easily populate two distinct columns using a pair of expressions:

  • Date Column: formatDateTime(utcNow(), 'yyyy-MM-dd')
  • Time Column: formatDateTime(utcNow(), 'HH:mm:ss')

This approach gives you structured, clean data that’s dead simple to filter, sort, and analyze in Power BI or other reporting tools. For more ways to use this and other functions, check out our guide on Power Automate expressions.

Got Questions? Let's Clear Things Up.

Even when you feel you've got a good handle on the power automate formatdatetime expression, a few common questions always seem to pop up. I've seen these trip up beginners and experienced pros alike, so let's tackle them head-on to save you some future headaches.

The most common error I see is the dreaded "'InvalidTemplate'. Unable to process template language expressions." message. Nine times out of ten, this simply means the timestamp you’re trying to format isn't in a structure Power Automate recognizes, like the standard ISO 8601 format. Before you start pulling your hair out, always check your input first. Is it a valid date string?

How Do I Handle Different Languages and Regions?

This is a big one. What happens when your flow needs to generate a date for someone in Germany, France, or Japan? Thankfully, the formatDateTime function has you covered with an optional third parameter for the locale code.

Let’s say you need to format a date for a user in France. You’d simply add the 'fr-FR' locale code to your expression:

formatDateTime(utcNow(), 'D', 'fr-FR')

This little addition completely changes the output to "dimanche 27 octobre 2024," which is exactly what a French user would expect. It's a small detail that makes a huge difference in global automations. You can find a complete list of these codes in the official Microsoft documentation on culture codes.

Here's a best practice I live by: keep your expressions as simple as possible. If a standard format string like 'd' or 'G' gets the job done, use it. Only dive into custom formats when you absolutely have to. It makes your flows so much easier for you (and your colleagues) to read, debug, and maintain down the road.

This isn't just about preference; it has a real impact. Simpler expressions mean fewer points of failure. In fact, development teams often report that reducing expression complexity can slash bug rates by up to 30%. By focusing on clarity and using the right tool for the job, you build automations that are not just powerful, but also reliable.


SamTech 365 is your source for expert guides on the Power Platform. For more in-depth tutorials and real-world solutions, visit https://www.samtech365.com.

Discover more from SamTech 365 - Samir Daoudi Technical Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading