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

How to calculate time differences in more than one fields and exponential calculations

Explorer ,
Feb 10, 2025 Feb 10, 2025

 

I want my "Total Activity Requested" to be the sum of all "Requested Dose" (i.e. fields R1-R10) 

 

Mathematically I'd want: 

Total Activity Requested = R1 + Sum of (Rx/exp(-0.00632*(Ax-Cal))     (where Rx = Fields R2-R10 and Ax = Fields A2-A10))

 

Ax-Cal is the time difference between the two fields in minutes

kennethkamchuh21426993_3-1739233908472.png

Using the above image as an example: 

For example R1 = 200 Cal: 11/02/2025 09:00   R2 = 250 A2 = 11/02/2025 10:00  R3 = 120 A3 = 11/02/2025 11:00 

 

The "Total Activity Requested" can be calculated to be = 200 + 250/exp(-0.00632*60) + 120/exp(-0.00632*120) 

 

I am expecting the answer to be 821. 

 

I hope this makes sense.

 

 

TOPICS
Create PDFs , JavaScript , PDF , PDF forms
90
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 ,
Feb 11, 2025 Feb 11, 2025
LATEST

- Calculation of time difference: This was discussed here many times in the past, including complete code examples.

Since your values contain the full date it should not be too difficult. You just need to convert them to Date variables (use the util.scand method), then deduct the latter from the former (using the getTime method of both variables), and convert the result from milliseconds to minutes.

- JS has a built-in command to calculate exponents: Math.exp(x)

which returns e raised to the power of x.

The rest of your calculation requires simple mathematical operators and should not be too difficult to implement.

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