Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I convert this excel formula into Javascript for Custom Calculation Script (in fillable PDF)

New Here ,
Jun 15, 2022 Jun 15, 2022

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.

 

TOPICS
Acrobat SDK and JavaScript , Windows
344
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 15, 2022 Jun 15, 2022

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 15, 2022 Jun 15, 2022
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines