web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Date Format / IF State...
Power Automate
Answered

Date Format / IF Statement

(0) ShareShare
ReportReport
Posted on by 52

Heya, I am trying to work out an IF statement that also changes the date format, and returns an empty space if there is no date from the field.

 

if(equals(formatDateTime(outputs('Get_item')?['body/field_19'], 'dd-MM-yyyy',''),null,formatDateTime(outputs('Get_item')?['body/field_19'])))

 

I though that would work but it returns this error:

 

The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '1' parameter(s). 

Categories:
I have the same question (0)
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @IndigoFaux,

    You have something syntax wrong with your expression.

    The if statement expects three parameters, the first parameter should be a complete formula that identify if the current date string is null.

    if(<condition>, <ifConditionIsTrue>, <ifConditionIsFalse>)
    if(empty(<dynamicContentWithDate>), <ifConditionIsTrue>, <ifConditionIsFalse>)

    Here is a complete if statement that if the current data string is empty, assign it with a null value, otherwise, format it as 'dd-MM-yyyy':

    Here I suppose that you have a date field in the SP list:

     

    if(empty(triggerOutputs()?['body/Date']), null, formatDateTime(triggerOutputs()?['body/Date'],'yyyy-MM-dd'))

    Or on your side, please modify as below:

    if(empty(formatDateTime(outputs('Get_item')?['body/field_19'], 'dd-MM-yyyy')),null,formatDateTime(outputs('Get_item')?['body/field_19'],'dd-MM-yyyy'))

     

  • IndigoFaux Profile Picture
    52 on at

    I still get this error with that formula:

     

    'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

  • Verified answer
    IndigoFaux Profile Picture
    52 on at

    if(empty(Outputs('Get_item')?['body/field_19']), null, formatDateTime(Outputs('Get_item')?['body/field_19'],'dd-MM-yyyy'))

     

    The above formula worked for anyone that might run into the same problem.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard