cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MikeMurillo
Regular Visitor

ParseDateTime Blanks? Issue with IF statement

Hello!

 

I can't seem to wrap my head around this, I feel like I'm ignoring something but I can't figure out what exactly.

I have a flow that creates an HTML table based on certain fields in an Excel file. I'm having issues with the format of the dates when there are blanks. I'm using an IF statement that leaves the field as null if the value is null, if it's not then format the date but always returns an error if there's a blank. 

 

Please note that I'm using ISO 8601 as the DateTime format. 

Data:

MikeMurillo_0-1654556518909.png  

Create HTML Table step:

MikeMurillo_2-1654556766040.png

 

Formula (I have tried several options, however none of them work):

1.

if(empty(formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy')), null, formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy'))

 

2.

if(equals(formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy'), null), null, formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy'))
 
3.

if(equals(formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy'), ''), null, formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy'))

 

This is the error that I get when the data has a blank:

MikeMurillo_3-1654556988268.png

 

The Input shows as ''

MikeMurillo_4-1654557071491.png

 

Thank you so much for your time, I would highly appreciate it if someone has any ideas on how to fix this.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
shoog
Dual Super User
Dual Super User

The problem is the parsedatetime function in the condition part, for the comparisson you should test against the original value like this:

 

if(equals(item()?['RESP_LAST_USED'], 'en-US', ''), null, formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy'))

 

View solution in original post

2 REPLIES 2
shoog
Dual Super User
Dual Super User

The problem is the parsedatetime function in the condition part, for the comparisson you should test against the original value like this:

 

if(equals(item()?['RESP_LAST_USED'], 'en-US', ''), null, formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy'))

 

MikeMurillo
Regular Visitor

@shoog Thank you so much!! Rookie mistake lol.

 

I had to change the formula to this in order to make it work!

 

if(equals(item()?['RESP_LAST_USED'], ''), null, formatDateTime(parsedatetime(item()?['RESP_LAST_USED'], 'en-US'),'MM/dd/yyyy'))
 
 

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (3,636)