How do I do a date calculation in an if statement? Example, I want this calculation…but, I have the syntax wrong:
If(Date < “04/01/2026, 0, 1)
If the date is older than the date I enter, then I want a result of zero else give me a 1
The field is a date field that I have formatted “MM/DD/YYYY”).
Hi Martha,
You’ll want to use the DATE() function to convert your date string into a proper date object.
IF(Date < DATE("04/01/2026", "MM/dd/yyyy")
The case of the pattern string on the right is important also. MM is for the month digits. dd is for the day, and yyyy is for the 4 digit year.
Thanks for the information. I can not get it to work…the DATE function seems to be calculating Dec 31, 1969 regardless of what date I enter or what date is in the Date field. I will email you my Form to see if you see what I am doing wrong.
My sincere apologies. I sent you down the wrong path. The right function to use is DATEVALUE() as that converts a textual representation of a date with a real date object. The DATE() function goes the other way around, converting a real date object into a textual representation of the date according to the pattern string provided.