cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MikeMurillo
Frequent 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
Frequent 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
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,701)