Power Automate: dayOfMonth function

Power Automate: dayOfMonth function

by: Manuel ⏱️ 📖 5 min read 💬 0

When you work with dates in Power Automate, you often need to know which day of the month a timestamp belongs to. The "dayOfMonth" function gives you exactly that: a single integer between 1 and 31. It is one of those tiny functions that you only think about until you need it, and then you reach for it every other flow. Together with the "dayOfWeek" function and the "dayOfYear" function, it forms a neat trio for slicing a date into the parts you actually care about.

Usage

The pattern is as simple as it gets.

  1. Date (as an ISO 8601 string)

Here's a simple example:

dayOfMonth('2026-03-15T13:27:36Z')

will return

15

If you want today's day of the month, combine it with the "utcNow" function:

dayOfMonth(utcNow())

will return (on the 26th) but your case may vary.

26

You can also pass in a value from a previous action, like a SharePoint date column or a variable holding a timestamp. As long as the value is a valid ISO 8601 string, the function will happily return the day number.

dayOfMonth(variables('orderDate'))

will return the day part of whatever date is stored in the variable

The return value is always an integer, never a string, so you can compare it directly against other numbers in your conditions without extra conversions.

Edge Cases

Timezone changes the answer

The "dayOfMonth" function reads the timestamp exactly as it is given, so the timezone embedded in the value drives the result. If you call it with the "utcNow" function close to midnight UTC, you may get tomorrow's day in Lisbon or yesterday's day in São Paulo.

Convert before you call

If your flow is meant to reflect local time, convert the timestamp first with the "Convert Time Zone" action or the "convertFromUtc" function, then pass the result to "dayOfMonth". Otherwise, your conditions that depend on a specific day could be triggered on a different day.

Date-only strings default to midnight UTC

If you pass a string like '2026-03-15' without a time component, Power Automate treats it as midnight UTC. That is fine in most cases, but combined with a later timezone conversion it can flip the day. Always include the time portion when precision matters.

Limitations

ISO 8601 only

The timestamp must follow the ISO 8601 format (for example, '2026-03-15T13:27:36Z'). If you feed it a string like '15/03/2026' or 'March 15, 2026', you will see something like:

Flow run failed. Action 'Compose' failed: Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'In function 'dayOfMonth', the value provided for date time string '15/03/2026' was not valid. The datetime string must match ISO 8601 format.'.

When your source data is in a different format, run it through the "formatDateTime" function first to bring it into shape.

Know your timezone

This trips a lot of people up, so it's worth explaining carefully.

A timestamp like '2026-03-15T13:27:36Z' looks unambiguous, but you still need to know what the value represents in your business logic. The "dayOfMonth" function trusts the string and gives you the day for that exact moment, regardless of which zone the rest of your flow assumes.

If you start with the "utcNow" function, you get a UTC value. If you then run that through the "Convert Time Zone" action and shift it to an extreme zone like "Line Islands Standard Time" (UTC+14), the string keeps the same shape but now represents a local time in that zone. Nothing in the timestamp tells you whether it has been converted, so track that intent yourself, especially when timestamps come from SharePoint columns, connectors, or user input.

No format or timezone parameter

Unlike the "formatDateTime" function, "dayOfMonth" takes only the timestamp. There is no second argument for locale, format, or timezone. If you need any of those, handle them in a separate step before calling the function.

Recommendations

Here are some things to keep in mind.

Convert to local time first

If the business meaning of "day of the month" is local, always convert the UTC timestamp before extracting the day. It is the most common source of off-by-one bugs with this function, and the fix is a single extra step in your flow. The "Know your timezone" limitation above explains why.

Use it for conditions, not display

The "dayOfMonth" function returns a raw integer, so it is perfect for conditions ("is today the 15th?", "is the day greater than 25?"). For anything you want to show a user, use the "formatDateTime" function with a pattern like 'dd' so you get a zero-padded string like '05' instead of 5.

Pair it with startOfMonth for monthly logic

When you need expressions like "the 15th of this month" or "the first Monday of the month", combine "dayOfMonth" with the "startOfMonth" function and the "addDays" function. It keeps the logic readable and avoids hardcoded dates.

Don't parse the string yourself

Don't try to slice the date string and pull the day out by hand. The "dayOfMonth" function is there to do exactly that, so let it do the work for you. Parsing strings by position is fragile, easy to get wrong on edge cases, and far harder to read than a single function call.

Always add a comment

Adding a comment will help others understand your formula. Indicate what the function is doing and why, especially if the expression is part of a larger conditional. A short note like "trigger only on the last business day" saves your future self a lot of time.

Final Thoughts

The "dayOfMonth" function does one job and does it well: it gives you the day part of a timestamp as an integer. Just remember to handle the timezone before you call it, and you will avoid the usual off-by-one surprises. It is a small building block that makes monthly schedules, billing cycles, and date-based conditions a lot cleaner.

Sources

Microsoft's "dayOfMonth" Function Reference

Back to the Power Automate Function Reference.

Photo by Y M on Unsplash

Comments

💬

No comments yet

Be the first to share your thoughts on this article!

Leave a Comment

All comments are reviewed for spam before being displayed 5000 left
Replying to