I have a function to import data from an Excel file and if
there are errors in the Excel data they are displayed in a grid. One of
the grid columns is a date called Expiration which will prompt an error
if the cell is empty or not formatted correctly. The database and model
types are of non-nullable DateTime so even if an empty date is imported
it's set to the DateTime minimum value of '01/01/0001', then displayed
in the grid as '01/01/1901'.
I'm trying to use a column template with an if/else statement to hide the date if it's invalid but the
documentation doesn't show
how to do a more complex comparison than a boolean check. I would like
to check if the Expiration date is set to the minimum DateTime value and
hide it.
I've
tried string comparisons but the "if" statement never evaluates to
true, and trying to use a Razor variable or JavaScript like "new Date()" breaks the script and it displays "#template" in each date field.
Also is it possible to apply formatting to the date within the template? In the index grid I use .Format("yMd") on the date to get "xx/xx/xxxx" but when the "else" statement in the template is run the date is displayed in long form, like "Tue Jan 01 1901 00:00:00 GMT-0600 (Central Standard Time)".
So far I have:
${if(Expiration === ???)}
//Empty span
${else}
${Expiration}
${/if}