Power Automate provides functions to add time-based on each of the units. For example, you can use the addSeconds Function to add only seconds, but the addToTime Function can provide a lot more flexibility since you define the unit that you want to add.
It follows a simple pattern.
- Number to add/remove
- Time unit to add
- (Optional) Date Format
addToTime('2019-10-28T10:10:00Z',10,'Second','yyyy-MM-ddTHH:mm:ssZ') will return '2019-10-28T10:10:10Z'
Looks quite straightforward, right? Positive numbers add seconds, and negative exclude them.
Please be aware that the reference material, Microsoft names objects like ‘2019-10-28T10:10:00Z’ as timestamps. I prefer calling them “Date” to avoid confusion with the UNIX timestamp, commonly used in APIs, to represent the number of seconds elapsed since Jan 01, 1970 (UTC).
Contrary to SharePoint and PowerApps, there’s no limitation to the date that you can use. You can do things like:
addToTime('1000-12-30T00:00:00Z',10,'Year','yyyy-MM-ddTHH:mm:ssZ') and you'll get 1010-12-30T00:00:00Z
Dates behave like you’re expecting them.
- Always include the format, even if the value is optional. The default value is “yyyy-MM-ddTHH:mm:ss:fffffffK,” but the date provided may not be in the same format returned or even trigger errors. You can define a single format specifier (for example, “o”) or a custom format pattern (for example, “yyyy-MM-dd”), so pick your favorite, but be sure to define it.
- I prefer to use individual functions instead of this function. For example, I prefer using the addSeconds Function since it makes the formula quite clear and shorter. It’s a matter of preference since the result will be the same.
Back to the Power Automate Function Reference