**daveprenter**Hello there, seems like I am always asking you guys for help.

I have set up an accommodation booking type form and would like to add a surcharge for any nights that people stay during certain holiday periods. I know I need to set up a condition along the lines "If date guest is staying falls between x and y dates then z surcharge per night is applied. I have set up the check in date picker but I cant' work out a way to calculate the number of nights that fall within a set period. I don't think it is possible but thought I would ask anyway......

Thanking you for all your help so far.

dave

**egeg**Hi Dave,

I was able to come up with a solution to your problem but it will require some changes on your form. Rather than asking for how many nights they will stay, I created a form that asks for a checkout date and calculates the difference and makes the calculations based on that. That is needed for the calculations to work, I hope that's ok.

Here is the form:

http://form.jotformeu.com/form/41142917307349?

Let me walk you through it real quick.

So the number of people, check-in and check-out dates are pretty straightforward.

"Number of nights" is a calculation widget:*Checkout - Checkin*

And then there's two "total fee" fields. Both of them are calculation fields:

For normal rates:*Number of nights * Number of people * 2*

For seasonal rates:*Number of nights * Number of people * 5*

The seasonal rate field is hidden by default(right click on the field to do so)

Then I created a condition like so:

Condition Image

So basically, if the check-in date is between 15th and 30th of May, it will hide the normal rate field and show the seasonal rate field.

Hope this helps. Please let us know if there's anything else we can do for you.

Thanks & have a good day!

Edit: Just a small tip. You may wanna uncheck default time on the checkout field and check the "wait for input" setting in the "number of nights" calculation in order for the form to not show negative numbers.**daveprenter**Hi egeg ,

Thank you so much for spending the time to do this. I was thinking of a similar solution using a date string to calculate the check out date. However , it unfortunately doesn't work. If someone starts their stay outside the holiday period, but cross over into the holiday period then ALL nights will be calculated at the non holiday rate. Conversely , if people begin their stay during the holiday period but cross over into the non holiday period then ALL nights would be calculated at the holiday rate, even though the last nights of their stay were outside the holiday period.

That is the problem I can't find a way around.

Do you have any ideas maybe using date string or something?

Or is it possible to get a custom script without changing my present form too much/

If not then I will just work around it.

Kind Regards,

Dave

--------------------------------------------

...- JotForm Support
**ashwin_d**Hello Dave,

I believe to achieve your requirement, you will have to download your form's source code and add some JavaScript code to find if the checkin/checkout fall between the given dates and calculate accordingly.

Please be noted that if you embed your form using its source code, any changes you make to your form in editor will not be reflected in your web page. You will have to download the form's source code and embed it again in your web page.

Do get back to us if you are okay to take the source code route and we will try to work on the custom JavaScript code.

We will wait for your response.

Thank you!

**daveprenter**Ok, well if that is the case I think it is easier just to work around it. I (believe it or not) would like to keep things as simple as possible. Thanks very much for your help anyway.

Kind Regards,

Davev

--------------------------------------------

...