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

FormatDateTime - null

(0) ShareShare
ReportReport
Posted on by 557

I have a Format Date Time   below  but the Complete Date sometimes may be blank so I'm getitng error that it can't accept a null value.  I'd still like the record to paste into excel even though it's blank.  How can I get around this?

FormatDateTime(outputs('Get_item')?['body/Complete_x0020_Date'],'M/dd/yyyy h:mm tt')

joel914823_0-1695144667134.png

 

Categories:
I have the same question (0)
  • Sundeep_Malik Profile Picture
    6,499 on at

    Hey @joel914823 

     

    You can write the following similar expression for this:

     

    1)

    if(equals(outputs('Get_item')?['body/Complete_x0020_Date'],''),null,formatDateTime(outputs('Get_item')?['body/Complete_x0020_Date'],'M/dd/yyyy h:mm tt'))

     

    2)

    if(equals(outputs('Get_item')?['body/Complete_x0020_Date'],null),null,formatDateTime(outputs('Get_item')?['body/Complete_x0020_Date'],'M/dd/yyyy h:mm tt'))

     

    What this will do is if the date is empty then it will add null in the excel sheet. If it has some value it will put according to how you have formatted the date above. Let me know if it works, if not I will give you another expression.

     

    I hope this helps 🙂

  • eliotcole Profile Picture
    4,390 Moderator on at

    Yo, @joel914823 , perhaps place an if() statement in there. 🙂

     

     

     

    if(
    	equals(outputs('Get_item')?['body/Complete_x0020_Date'], null), 
    	' ', 
    	FormatDateTime(
    		outputs('Get_item')?['body/Complete_x0020_Date'],
    		'M/dd/yyyy h:mm tt'
    	)
    )

     

     

     

    Or, if it is potentially having 'blank' values, then you can get a bit more creative with:

     

     

    if(
    	equals(outputs('Get_item')?['body/Complete_x0020_Date'], null), 
    	' ', 
    	if(
    		or(
    			equals(outputs('Get_item')?['body/Complete_x0020_Date'], ''),
    			empty(outputs('Get_item')?['body/Complete_x0020_Date'])
    		), 
    		' ', 
    		FormatDateTime(
    			outputs('Get_item')?['body/Complete_x0020_Date'],
    			'M/dd/yyyy h:mm tt'
    		)
    	)
    )

     

    Also, not for nothing, mate ... but I don't usually say this ... but it looks like you've taken my advice in the other thread ... if you can mark my (or whomever's!) answer there as the answer then it helps others that turn up to find answers quickly to the same issue. 👍

     

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard