What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    How can I count days between dates ?

    Asked by George  on February 08, 2014 at 12:22 PM

    If I have two dates for exaples:

    DATA1:02/02/2014 ond DATA2:04/03/2014

    JotFoam using option CALCULATE FIELD and equation [{DATA2}-{DATA1}] result is 2 but its wrong,  the correct result should be 30 couse days between DATA2 and DATA1 are 30.


    Is it error in JotFoam or I do something wrong ? How to count days between two dates ?

     

    Thank you for answer.

    count calculate field and two dates
  • Profile Image
    JotForm Support

    Answered by abajan on February 08, 2014 at 03:29 PM

    Hi George,

    Interestingly enough, just yesterday another user asked about this very issue. If you need to apply the solution I provided there to a specific form and would like help, please let us know.


    Thanks

  • Profile Image

    Answered by ParkingRetkinia on February 08, 2014 at 04:22 PM

    Hi, George is the same of ParkingRetkinia :-)

     

    I have got the same problem, but i need have the return value of the number of days in
    the text box so that the wizard will create rules discovering the price of parking for a given quantity does not. I'm not so great knowledge to do it. Can you help me?

    My form number http://polski.jotform.com/jsform/40376156246354

  • Profile Image
    JotForm Support

    Answered by jonathan on February 08, 2014 at 08:41 PM

    Hi George,

    I see that you have also commented on this thread already -calculate-amount-of-days#10

    What you wanted to achieve is very much possible using also the form's source code.

    The only difference in your case is containing the output of the calculation days on a Textbox field.

    Do you have a website where you can use the form's source code and as well us capable of adding javascript code?  This is a primary requirement.

    We can modify the code given by our colleague in that other thread to make it applicable in your form version.

    We will wait for you updated response.

    Thanks.

  • Profile Image

    Answered by ParkingRetkinia on February 09, 2014 at 05:45 AM

    Hi

    Yes, i have website where I use JotFoam http://www.parkinglublinek24.pl/rezerwacje.html (this is my website for reservation of parking placed for airport i Poland - Lodz) and I also can add javascripts ass well. I only dont know were, how and in which file change the code. Ofcourse I know, the code have to be input on my website, not using direction from your server :-)

    I should be grateful for modification and instructions on how to make changes using Texbox field.

    What shiuld i do ?

    George

  • Profile Image
    JotForm Support

    Answered by EltonCris on February 09, 2014 at 07:25 AM

    Hi George,

    Thanks. I can see the form on your site however, I just have one question. I can see the two date fields on your form, but I don't see any textbox field where the result (number of days) should be placed? Do you want it to be on a textbox field so it can be captured and included on the email or do you want the result to appear as text on your form just like the demo provided by my colleague Abajan?

    We'll get back to you later today with all the instructions on how to implement it on your form.

    Regards!

  • Profile Image

    Answered by ParkingRetkinia on February 09, 2014 at 09:27 AM

    Now I have just changed tre foam. Now you can see TextBox named DNI POBYTU with implementation of  calculated dates ( [{DATA....). When you change date in the same month then appears the price of the parking (you can try). And in this configuration, I would like to make it work :-)

     

    I hope I had understood your needs :-)

    Oh..and I hope that my English is understandable for you :-)

  • Profile Image
    JotForm Support

    Answered by NeilVicente on February 09, 2014 at 11:42 AM

    Elton will get back to you once the codes are available.

    Cheers!

  • Profile Image
    JotForm Support

    Answered by EltonCris on February 09, 2014 at 06:03 PM

    @ParkingRetkinia

    Here's the script needed for the calculation. http://pastebin.com/raw.php?i=4xxWkezi

    To apply it on your form source code,

    1. Get your form source code in the form builder and paste it to notepad.

    2. Copy the calculation script from the link above and paste it below the form source code.

    3. Save the form as HTML file e.g. myform.html and upload it to your server or you can actually embed the entire source code directly on your website.

    Demo: https://shots.jotform.com/elton/workaround/number_of_days.html

    If you need further clarification, let us know here.

    Regards!

  • Profile Image

    Answered by ParkingRetkinia on February 10, 2014 at 04:38 PM

    Hi

    THANK YOU  MASTER ! Counting  the days between the months is correct...but now is another problem and i dont know why:

    Look: http://www.parkinglublinek24.pl/rezerwacje.html

    Everything is perfect in the same month. Rules (hide - show) of prices works good, but only if i hange month ex. 10.02.2014 - 1.03.2014 everything is wrong (wrong is of showing price in {doZaplaty41}, ofcore you counting the days works perfect). The calculating  in {doZaplaty41} is [150+(({dniPobytu20}-15)*10)] but 150+((20-15)*10)=200....NOT 80 as calculated form does


    Where is mistake ? In the same month everything is fine, rule are working, calkulation is correct.

    Very strange...

     

    Thanks

  • Profile Image
    JotForm Support

    Answered by EltonCris on February 10, 2014 at 06:29 PM

    Hi,

    Please update your script with this: http://pastebin.com/raw.php?i=Q2tCLZB1

    Demo: https://shots.jotform.com/elton/workaround/330235_demo.html

    I think there is no need to create calculation on the form builder so it is safe to removed the formula created on the calculation wizard. 

  • Profile Image

    Answered by ParkingRetkinia on February 11, 2014 at 03:54 AM

    Thanks

    But stil not working. First of all rule wizard can not remove the equation once introduced, despite the removal and pressing SAVE. When you enter to CALCULATE FIELD the equation is still there :-(

    Second of all rules wizard is not working at all. You have enter the equation in to the script that i enter to the code using notepad but the result in cell input_43 (formerly input_41) is incorrect.

    Price list of our parking is:

    1-3 days = 60

    4 days = 70

    5-6 days = 80

    7-8 days = 90

    9 days = 100

    10 days = 110

    11 days = 120

    12 days = 130

    13 days = 140

    14-15 days = 150

    Every 1 day over 15 days price is 10, so that why I'm using RULES WIZARD (show, hide) and equal 150-((input_20)-15)*10

    Now usingrules wizard foam shuld show or hide cells named DO ZAPŁATY and if days in cell input_20 are more than 15 cell input_43 shuld show up and calculate the correct price.

    I hope now you understand my problem.

    Now form seems not to take into account the wizard's rules and has only the equation, regardless of the rules and behavior of cells show up to 15 days

     

    Thanks


  • Profile Image
    JotForm Support

    Answered by EltonCris on February 12, 2014 at 02:57 AM

    @ParkingRetkinia

    Sorry for the delay.

    I can't seem to reproduce the problem you've mentioned. I am able to removed the formula on the calculation wizard. Can you please refresh the page by hitting (Ctrl + F5) and check it again? It should be fine. I guess this isn't needed. Fomula doesn't seem to exist anymore.

    I can see that you've updated the total field so it is now assigned with different field ID. To correct my previous script,

    1. Just look for the line grandtotal = $('input_41'); on my previous code.

    2. Replace input_41 with input_43

    ----

    The last issue seems pretty complex. Honestly, things are getting complicated due to your conditions. There were issues on your form conditions that's why the hide/show does not work as intended. This is also the reason why calculations does not interact properly with hide/show conditions. Anyway, I have cloned your form here and fixed the conditions base on your inputs. Hopefully this form http://form.jotformpro.com/form/40418357324957? performs the right hide/show condition. Please clone this form back and after that, take the form source code on the cloned form and apply this script. http://pastebin.com/raw.php?i=xhnZjTY4

    Output should perform like this: https://shots.jotform.com/elton/workaround/thread_330235_test.html

    Thanks!

  • Profile Image

    Answered by ParkingRetkinia on February 13, 2014 at 05:34 AM

    Fabules :-) Thank you very very much but...i can not import your foam to mine profile...I'm taking IMPORT FOAM, FROM WEBSITE, pasting link http://form.jotformpro.com/form/40418357324957 and...

    "No form found on the page. Please check the source code you provided"
    I've tried many ways..always answer is like abowe.

    How to import your foam to my profile ?

  • Profile Image
    JotForm Support

    Answered by EltonCris on February 13, 2014 at 05:38 AM

    I just realized my forms aren't set to be cloned. It should be this time. Please try it again. :)

  • Profile Image

    Answered by ParkingRetkinia on February 13, 2014 at 10:26 AM

    Bdi bdi bdi THAT'S ALL FOLKS :-)

    THANK YOU VERY VERY VERY MUCH FOR YOUR HELP !

    Precedence once encountered such a professional, rapid and specific service.

    Keep up and going to get very far! I will be recommending your work among my friends

    And again THANK YOU !

  • Profile Image

    Answered by ParkingRetkinia on February 16, 2014 at 04:41 PM

    I have realized that when numbers of cars is greater than 1 price have o be multiplied by the number of cars.
    Cells length of stay in the number 15 was easy for me, i have changed cels using CALCULATION FIELD.

    But extra SCRIPT, that I put into the code is to hard to change for me:

    //[150+(({dniPobytu20}-15)*10)]
    getGrandTotal = function(){
      var grandtotal = $('input_43');
      if (finaltotal.value > 15) {
       // alert('test');
         grandtotal.value = (150)+((finaltotal.value - 15)*10);
    }
    };

     

    I don't know how multiply this value in cell INPUT_16

    Can you help me ?

  • Profile Image
    JotForm Support

    Answered by jonathan on February 16, 2014 at 05:26 PM

    Hi,

    You can try modifying the script code part to like this

     

    //[150+(({dniPobytu20}-15)*10)]

    getGrandTotal = function(){

      var grandtotal = $('input_43');

       var NoofCars = $('input_16');

      if (finaltotal.value > 15) {

       // alert('test');

         grandtotal.value = (150)+(((finaltotal.value - 15)*10) * NoofCars);

    }

    };

    basically, I added a new variable NoofCars to get the value of input_16 (number of cars) and multiplied it to the computation of grandtotal.value

    Please try this. Inform us if the result does not work.

    Our colleague EltonCris who originally created the solution will probably comment here also when he is back online.

    Thanks!

     

     

  • Profile Image

    Answered by ParkingRetkinia on February 16, 2014 at 05:36 PM

    Thank alot but it's doesn't work :-( The result is "NaN" in price cell.

  • Profile Image
    JotForm Support

    Answered by EltonCris on February 16, 2014 at 06:29 PM

    @ParkingRetkinia

    From my colleague's suggestion, just append .value on NoofCars variable so it becomes like this:

    //[150+(({dniPobytu20}-15)*10)]

    getGrandTotal = function(){

       var grandtotal = $('input_43');

       var NoofCars = $('input_16');

      if (finaltotal.value > 15) {

         grandtotal.value = (150)+(((finaltotal.value - 15)*10) * NoofCars.value);

    }

    };

    That should return the value instead of NaN :)

    Regards!

  • Profile Image

    Answered by ParkingRetkinia on February 17, 2014 at 04:44 AM

    Thank you, it works :-) Only i have changed mathematical part for:

    (((150)+((finaltotal.value - 15)*10)) * NoofCars.value);

    but this i know how :-)

     

    Thanks alot again :-)

  • Profile Image
    JotForm Support

    Answered by jonathan on February 17, 2014 at 08:31 AM

    Thank you for updating us. Contact us again anytime for any assistance you need.