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

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

New Here ,
Jun 15, 2022 Jun 15, 2022

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.

 

TOPICS
Acrobat SDK and JavaScript , Windows

Views

50

Likes

Translate

Translate

Report

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

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.

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

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