How do I convert this excel formula into Javascript for Custom Calculation Script (in fillable PDF)
Copy link to clipboard
Copied
My Excel formula is =IF(A3>=DATE(2022,1,1),0.53,0.5)
This looks at a cell (e.g., A3) and determines whether or not the date in that cell is after Jan 1, 2022. If it is, then the value is .53 and if not, it is .50. The purpose of this formula is to auto-caluate mileage reimbursement rates.
I am not familar with Javascript, though I've been able to learn some things online (how to code if/thens). What I can't figure out is how to represent "greater than xx/xx/xx date" in JS.
Copy link to clipboard
Copied
You will need to convert the string to a Date object. This can be done using the scand method of the util object.
Then create another Date object representing this cut-off date, and compare the two by accessing their getTime methods, which returns a number.
Copy link to clipboard
Copied
Unfortuantely I am not well enough versed to make sense of this, though I'll definitely look into your suggestions and see if I can piece some code toghether.

