Please note what makes the code from @Tom work is that he does arithmetic (subtracting 2) on UN-formatted date values. Once ALL arithmetic and logical operations are done, then and only then, should you format the results and only if you need to do that
Do not try to do logical or arithmetic operations on formatted dates. Do not try to work with formatted dates (which are character strings) to perform any operations, other than to use the formatted dates in titles, labels or file names.
... View more