Trouble with "parseDateTime()" in Power Automate

Callum Knight 45 Reputation points
2025-06-12T02:16:42.1766667+00:00

I'm attempting to use the following expression to replace the 'content' attribute in my OneNote page HTML, effectively setting the page creation timestamp before the page is created (because I can't find another way to do so). Please see below:

replace(string(body('Get_Template_Page_Contents')?['$multipart'][0]?['body']), '"2025-06-06T07:30:00.0000000"', string(parseDateTime(variables('currentDateTime'), 'en-AU', 'yyyy-MM-ddTHH:mm:ss.fffffff')))	

The variable 'currentDateTime' is a string collected from a SharePoint item's 'Created' column. I'd then like to format that timestamp into the same format used in the OneNote HTML, then replace it.

The issue I'm facing is this:

Unable to process template language expressions in action 'Multipart_1_-_Body' inputs at line '0' and column '0': 'In function 'parseDateTime', the value provided for date time string '2025-06-12T01:47:58Z' was not valid. The datetime string must match ISO 8601 format.'.

I can't wrap my head around it as I'm sure that is correct ISO 8601 format. Am I horribly wrong or is there something else wrong with my expression that is causing this error?

Any help is greatly appreciated, thank you.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,685 questions
{count} votes

Accepted answer
  1. Leena Abdalla Mohamed Abdalla 75 Reputation points
    2025-06-12T20:58:13.8633333+00:00

    The issue with parseDateTime() likely stems from how it handles the Z suffix in your timestamp. A working alternative is to split the timestamp at 'Z' and manually append the required fractional seconds:

    PowerApps

    string(concat(split(triggerBody()?['Created'], 'Z')[0], '.0000000'))
    

    For a more streamlined approach, convertTimeZone() is recommended, as it allows both formatting and timezone conversion in one step. This ensures compatibility with OneNote's expected format.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.