How to use ‘missing’ date dynamic content in Power Automate expression

“I’m missing the dynamic content with a date when building an expression to formatDateTime(…) in Power Automate. How can I build the expression without it?”‘


Formatting a date in Power Automate flow is one of the commonly used expressions. You just put a dynamic content with a date into a formatDateTime() expression and get a date in the desired format. But how can you use the dynamic content if it’s missing? It’s available when used directly, but once you start typing an expression it’s gone.

power automate missing date dynamic content expression

Add ‘Compose’ action

The simplest solution is to add a ‘Compose’ action with the date in your flow. Add it just before the current action where you want to use the expression. Enter the date as the ‘Compose’ input and then use output from that action in the expression itself. It’s a solution used in the previous post on building approval history.

formatDateTime(outputs('Compose'),'yyyy-MM-dd')
power automate approval flow history

Type in the dynamic content

Another, cleaner but more complicated approach is to ‘type in’ the dynamic content into the expression by yourself. Even if Power Automate doesn’t show it, the data is still there. You just need to type in the ‘dynamic content’ manually into the expression.

As you probably noticed when using dynamic contents in expressions, it’s always a different string. It’s not just ‘Date’, it can be something like ‘items(‘Apply_to_each_2’)?[‘Date’]’. And that’s format of the string you must type in.

Or you take the string directly from the flow. Add a compose action to your flow in the same way as above. But this time, instead of using output from the action you select > copy > paste the dynamic content into a text editor. The string will have format as below.

@{items('Apply_to_each_2')?['Date']}
power automate get dynamic content

As you can see, it’s similar to the string used in the expressions. There’re just 3 characters you must remove: @, { and }.

@{items('Apply_to_each_2')?['Date']} remove @, { and }
=>
items('Apply_to_each_2')?['Date']

And that’s the string you use in the expression. Add the string inside the expression and Power Automate will process it.

formatDateTime(items('Apply_to_each_2')?['Date'],'yyyy-MM-dd')
power automate expression with dynamic content

Once you enter the expression, you can remove the original ‘Compose’ action you used to get the dynamic content string.

Summary

Power Automate is sometimes really user unfriendly. The user interface has all the data, but it just doesn’t want to help you build the expression. But there’s always a workaround. And this time it’s either adding another action to your flow, or doing a bit of ‘coding’ by yourself.

Both the solutions above will achieve the same result: you get access to a ‘missing’ dynamic content. The only situation where the ‘Compose’ solution will not work is in actions using a whole array, e.g. ‘Filter Array’ or ‘Create HTML table’. In all the other flow where you process items one by one it’s up to your preference which solution you use.

Also, the solutions above don’t apply only to dynamic content with dates. You can use the same approach in all situations where the expression doesn’t offer you the dynamic content, e.g. when avoiding corrupted email attachments.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to a special content like a SharePoint Filter Query cheat sheet.

Zero spam, unsubscribe anytime.

Add a Comment

Your email address will not be published. Required fields are marked *