formatDate and empty string

Hi Team - this is one i should know but i can’t make it work. I have a query returning data from a database. Within that data there are dates. I use formatDate to… well, ya know, format the date. Problem is sometimes the date is empty and it returns an error because you cant format an emptystring.

I have tried functions with if, ifempty and switch. I have used “”, null and emptystring but i can’t get it to work but it continually comes back saying cant format an emptystring.

Looking at the data returned in the history it shows the date as “empty”.

Can someone point me in the right direction?

Hello @IainM nice to meet you.

Did you tried to use this function?

Don’t hesitate to contact us if you require further assistance.

//Vlad

yup. it was still generating an error on the formatDate.

Were you ever able to figure this out? The only thing I can think of is to use an ifempty( ) and push a dummy date when the imported data is blank which is less than desirable.

EDIT: I think I figured it out:

if(date != null; formatdate(date;YYYY-MM-DD);)

If date field is not empty, return the formatted date, otherwise return nothing

Hey @Jon! :wave:

Just wanted to give you a quick shoutout and say thanks for sharing your solution with the community. It’s really appreciated and super helpful! :pray:

@IainM, have you had a chance to check out the solution proposed by Jon? Feel free to let us know if it’s something that could work for you. No rush!