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 / Flow condition using d...
Power Automate
Answered

Flow condition using date not working when date is null

(0) ShareShare
ReportReport
Posted on by 12

I have a flow where the for a date column i am formatting this and adding it to an excel file.

 

When the date is null the flow fails as a string rather than null.

 

Any ideas on how to resolve this? below is the error message:

 

Unable to process template language expressions in action 'Formatted_case_resolved_date' inputs at line '1' and column '3097': '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.'.

Categories:
I have the same question (0)
  • Verified answer
    DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @ryanb888 

     

    Without seeing the action you are using, you could use a compose with an if expression.  For example:

     

    if(empty(dynamicdatevalue),'',formatdatetime(etcetc,'yyyy-MM-dd'))

     

    This would check for your date value being empty, and if so output '', otherwise it would use the formatdatetime.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

  • Pstork1 Profile Picture
    69,513 Most Valuable Professional on at

    Empty() is for determining Empty strings.  The better choice here would be to use Coalesce().  Coalesce process the parameters from left to right and accepts the first one that isn't null.  So you can supply your date as the first entry and a default date as the second.  If the first entry is null the second will be used.  Something like this

    formatdatetime(colalesce(DateTimeField,'1900-01-01'))
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Nice one @Pstork1 !  Thank you for that. 👍

  • ryanb888 Profile Picture
    12 on at

    thanks for your reply, my existing code is formatDateTime(triggerBody()?['efa_resolvedon'],'yyyy/MM/dd'))

     

    in your code provided would you be able to incorporate the trigger body? or is your code an alternative for formatting the data where trigger body is not required?

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    HI @ryanb888 

     

    Your example is correct.

     

    if(empty(triggerBody()?['efa_resolvedon']),'',formatDateTime(triggerBody()?['efa_resolvedon'],'yyyy/MM/dd')) 

     

    Damien

  • Pstork1 Profile Picture
    69,513 Most Valuable Professional on at

    Sure,  the code when using Coalesce would be as follows:

    formatDateTime(coalesce(triggerBody()?['efa_resolvedon'],'2021-01-01'),'yyyy/MM/dd')

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 470

#2
Haque Profile Picture

Haque 416

#3
David_MA Profile Picture

David_MA 344 Super User 2026 Season 1

Last 30 days Overall leaderboard