cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
n8greene
Level: Powered On

Formatting a date value from a column that might have a null value

Scenario: I am creating a CSV from a SharePoint list. One of the columns, StartDate, is sometimes blank. The date needs to be formatted. 

 

To get around the NULL error this works: Coalesce(item()?['StartDate']) BUT I need to format the date. 

I can format the date this way: formatDateTime(item()?['StartDate'],'yyyy-MM-dd') BUT then I get NULL errors. 

 

I cannot figure out how to avoid NULL errors AND format the date. Any suggestions?

 

These do NOT work: 

formatDateTime(coalesce(item()?['StartDate']),'yyyy-MM-dd')

coalesce(formatDateTime(item()?['StartDate'],'yyyy-MM-dd'))

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
n8greene
Level: Powered On

Re: Formatting a date value from a column that might have a null value

I kept experementing with different approaches and this worked:

 

if(equals(item()?['StartDate'], null), '', formatDateTime(item()?['StartDate'],'yyyy-MM-dd'))

 

(note that the '' in the formula is two single quotes)

View solution in original post

1 REPLY 1
n8greene
Level: Powered On

Re: Formatting a date value from a column that might have a null value

I kept experementing with different approaches and this worked:

 

if(equals(item()?['StartDate'], null), '', formatDateTime(item()?['StartDate'],'yyyy-MM-dd'))

 

(note that the '' in the formula is two single quotes)

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,589)