How to check if a date has a specific format

I’m trying to get an expression for (if the value in the column is not as date dd/MM/yyyy, then it gives me an error in the rules, but I can’t find such expression, I looked for all the cases in the community but nothing matches what I’m after. Can you please suggest how it can be done?

I have done this expression {IF format([OrderDate], 'dd/MM/YYYY') }, but it doesn’t work.

You can check if a date has the "dd/MM/yyyy" format by trying to parse it using the date() function (it's the opposite of format()). If parsing fails, then it's not the expected format.

When the parsing is successful, the result is a number. When it fails it's an error. So we can use the isnumber() or iserror() functions to verify the data type of the result.

For example:

isnumber(date([Dates], 'dd/MM/yyyy'))

See the example below:
is-date.morph (2.7 KB)


Dear Dmitry,

Thank you for your answer, please check the attached, my aim is to use rule function to check valid dates, if it is invalid, I want to use the (then) function, please the excel sheet which has invalid dates input, and the .morph file
Invalid Dates.morph (4.6 KB)
Sales Order Lines invalid date.xlsx (8.6 KB)

Oh, that's a bit different. These dates are already valid dates because they are number dates, not text dates. To understand the difference better, see this tutorial article: EasyMorph | Type system and expressions

In EasyMorph, like in Excel, dates are numbers, just formatted as dates. For instance, 42680 corresponds to November 6th, 2016. However, in EasyMorph column can have formatting (sometimes applied automatically) that forces numbers to be shown as dates in the datagrid. Such formatting doesn't modify values, it only changes the way the values are shown in EasyMorph.

In your workflow, the dates in question are numbers. You can see it by several hints:

If you anticipate that some of the dates in the future may be imported as text dates, not as number dates, or it can be a mix of both, then you need to add a check whether the values are already numbers (i.e. valid dates):

Here is the updated project:
Invalid Dates.morph (4.9 KB)