Need help with calculating value

  • Omar_ol
    Asked on March 28, 2025 at 5:44 AM

    How can I make sure that a formula like

    Date picker FIELD-Date pickerFIELD/365

    actually work?

    /365 or any other formula I add either becomes grayed or if black as a number, it automatically breaks up into blocked digits. Either way never does it divide the difference. I keep getting strange #s or a # with some symbols. I have tried to re-enter over 20 times.- rebuilding the simple formula.

    it seems like the /365 is not being treated as numeric values?


    We need to collect 5 years of residence - and we've tried the date difference widget but it didn't work. SO, trying two values- and at least let people know if they have entered enough history- if the dates they entered (start/finish) are less or more than 5 years.


    thanks

  • Manilene JotForm Support
    Replied on March 28, 2025 at 8:29 AM

    Hi Omar,

    Thanks for reaching out to Jotform Support. It sounds like JotForm's calculation field isn't properly interpreting the /365 division, which is causing unexpected outputs. Here are a few things to try:

    1. Make sure your formula is structured clearly: (Date Picker FIELD - Date Picker FIELD) / 365. Parentheses help JotForm understand the order of operations.

    2. Check that both Date Picker fields are set to output their values as Numbers rather than Text. If they are text-based, JotForm won't be able to subtract them correctly.

    3. Instead of entering the formula directly, do this:

    1. Add a Form Calculation Widget.
    2. Click on the widget to Edit it.
    3. Insert both Date Picker fields.
    4. Subtract them (Date Picker END - Date Picker START).
    5. Manually insert / 365 as a separate numeric entry, ensuring that it is not treated as text.

    4. In the Form Calculation Widget, click on the three-dot menu and select Decimal Places, then set it to 2 or 3 to ensure you get accurate results.

    If the calculation still fails:

    1. Use a Hidden Form Calculation Widget to convert both date fields into timestamps.
    2. Subtract them and divide by (1000 * 60 * 60 * 24 * 365), which converts milliseconds into years.

    5. Apply Conditional Logic for 5-Year Check

    If you want to warn users:

    1. Create a Hidden Calculation Field for the years difference.
    2. Use Conditional Logic:
    3. If the value is less than 5, show a message saying "You need at least 5 years of residence."
    4. If it's 5 or more, allow the form to proceed.

    Give it a try and let us know if you have any other questions.

  • Omar_ol
    Replied on March 28, 2025 at 4:21 PM

    yes, I have tried all this. even a multiplication version. The issue is that when I start from scratch and follow each step, the /365 part always either gets greyed or turned to black #s and separate little boxes. somehow this interferes. I have even tried to remove and insert a new widget to calculate. Is there a way to just force that /365 to remain as a numeric value? I've done it so many times and then I have to preview and enter the dates so many times to test and only to get strange #s. when I do it only with the - , I do get the correct # of days. a year apart gives me 365. why does simply adding /365 not equal 1. it seems simple. and re-doing it over and over again does not help- have also tried the ( ) option.

    for example if I do this:

    (Date Picker END - Date Picker START)/365.25

    I get "365/365.25" when I test out dates one year apart. The date picker entrees are in blue- and /365.25 is automatically grayed out.


  • Ronald JotForm Support
    Replied on March 28, 2025 at 6:59 PM

    Hi Omar,

    Can you share the link of the form that you're working with and a screenshot of the field that have the formula so we can further check the issue? Let me show you how to post a screenshot to our Help Center:

    1. On the Help Center page, scroll down to the Your Answer section and click on the Image icon.

    2. Drag and drop your image into the Upload box, or click on it and select your file.

    3. Then, click on the Add button in the bottom-right corner of the window.

    Need help with calculating value Image 1 Screenshot 30

    4. To resize it, click on your screenshot and then click on one of the boxes in the corners, and drag it inward.

    5. Once you're finished, click on the Post Answer button at the bottom right of the Your Answer section.

    Need help with calculating value Image 2 Screenshot 41 That's it. Once we hear back from you, we'll be able to help you with this.

  • Omar_ol
    Replied on March 28, 2025 at 7:20 PM

    I just need to know how to force the /365 to be calculated.

    I already get the correct # of days. but the grayed out or black boxes, etc..that happens automatically - none work. Need help with calculating value Image 1 Screenshot 40Need help with calculating value Image 2 Screenshot 51Need help with calculating value Image 3 Screenshot 62

  • Omar_ol
    Replied on March 28, 2025 at 7:47 PM

    after looking at what was guided and what I've found online, this isn't working. I will just have to let people do their own indication if they need to add more dates - calculate if they provided 5 years worth. I thought this would work easier. it may be an issue that needs to be fixed. Just spent too long and we may end up with issue sin the future.

    thanks

  • Mary JotForm Support
    Replied on March 29, 2025 at 4:04 AM

    Hi Omar,

    The grayed out numbers means they are being calculated as strings and not as numbers. You need to just click on the numbers to convert it to numeric values in the form calculation widget. Here is an example:

    Need help with calculating value Image 1 Screenshot 40

    As for your formula of Date Picker field - Date Picker field /365, it should work. Here is an example:

    Need help with calculating value Image 2 Screenshot 51

    Here is the result:

    Need help with calculating value Image 3 Screenshot 62

    Give it a try and let us know if you have any other questions.

Your Answer