How to validate a best-before date?

Validating a date code will help operators ensure that date codes are correctly assigned and within specification. This article guides you through validating the date field based on the Product Life in a form.

Validating Date Fields in Fusion Manager


Step 1 -
Invalid when the date is no greater than the number of 'x' days.
I.e. No greater than Product Life days.

NOTE: When a form is triggered, a timestamp in seconds is recorded. This is called an epoch timestamp.
The 'Convert to Date' tool converts epoch timestamp to a date.

data["Date"]>dateAdd(date(alert["createTime"]),jobmeta["ProductLife"],"days")


Step 2 - Invalid when the date is no less than the number of 'x' days.
I.e. no less than Product Life days.

NOTE: The '+1' takes into account the entire day of which the form was raised as the form will take into account the exact time in seconds rather than the entire day starting from 12am. 

dateAdd(data["Date"],(+1),"days")<dateAdd(date(alert["createTime"]),jobmeta["ProductLife"],"days")


Step 3 - Valid when the entry of the date is equal to our target.

data["Date"]<=dateAdd(date(alert["createTime"]),jobmeta["ProductLife"],"days")


Here is how it will look for users: