How to ‘Get changes…’ based on date and time in Power Automate
Posted On October 6, 2021
“I’d like to use the Power Automate action ‘Get changes for an item or a file’ to return all changes since a date, but all I get is error: ‘Invalid format for version input value’.”
The ‘Get changes for an item or a file (properties only)’ action will give you information if a column was updated. You can take changes in the last update, changes between multiple versions, or changes based on a date. The date value is useful if a SharePoint item is updated multiple times a day, or if users edit the item in the display form. In both situations you’ll have multiple item versions during a day, maybe too many to process them one by one. And if there’s a flow connected to those updates, it might be better to run it only once and process all those changes.
The problem is that if you use a date in the ‘Get changes…’ action, you’ll probably end with an error: Bad request. Invalid format for version input value.
The action doesn’t like the date format.
Format the date in the right format
If this long date and time is not what the action wants, how do you find the right format? Don’t rely on the description, it’s wrong. If you use the recommended format, it’ll fail again.
The best way to find the format is to run the action with an input that works, and then check what it looks like. Let’s use the ‘Modified’ date.
Run the flow and check the flow run history. If the action was successful, then the format must be correct.
That’s the format to use for your custom date, e.g. to get all updated columns since the start of the day with the startOfDay(…) expression. It’s a similar expression to the startOfMonth(…), but this one will return start of a day.
Add the desired format:
And use it in the ‘Get changes…’ action to get all today’s changes.
If you want to get all changes since a specific date, you must use the format Power Automate wants. In this situation is the action description a bit misleading, but a successful run isn’t. Try to use one of the available dynamic contents, and if the flow runs fine, that’s the format you need. Then just replicate that format for your date.