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

Notifications

Announcements

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
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard