Search code examples
power-automate-desktop

formatDateTime in Power Automate Desktop


I am trying to assign the current datetime to two variables in Power Automate Desktop - one as the date in yyyyMMdd format and one as the time in HHmm format.

The steps I have is to use 'Get current date and time' and store that value into the variable CurrentDateTime.

I have then created a variable called Date and I'm setting the variable value to be %formatDateTime(CurrentDateTime,'yyyyMMdd')% and set the time variable to %formatDateTime(CurrentDateTime,'HHmm')%

I keep receiving the error Function name 'formatDateTime' is invalid. What am I doing wrong? Microsoft lists formatDateTime as an expression here https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#formatDateTime


Solution

  • You are confusing Power Automate with Power Automate Desktop. The link you provide is for Power Automate, so those functions won't work in the PADesktop.

    There is an action named Convert datetime to text in PAD, you can specify the formats you would like there

    The action lets you pick from existing formats or you can specify one. action convert dt to text

    copy this code to PAD to see a custom example

    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyy*MM*dd HH`mm''' Result=> FormattedDateTime