# Calculate Price Based On Days

Hey there! I have to make a very simple formula but having problems on how to write it correctly

I have two date fields (arrival, depature)
I have a Total days field ( calculates the date difference) -working

I have a price field that shows price for the spesific amount of days I have the formula:

IF({Dager} = 1, "590, ") &
IF({Dager} = 2, "690, ") &
IF({Dager} = 3, "840, ") &
and so on all the way to 21 days ( everything here is working fine)

BUT, after day number 21, the price is gonna add 20 for each day.

Itâ€™s going to be something like this:

If({dager)>21, ({dager},-21*(20),1490, ")

Example with 29 days - If({dager)>21, ({29},-21*(20),1490, ")

• Here the days over 21 is 8. Then multiply 8 by 20, then + 1490 (price for 21 days)
And the total is then 1650, which is correct.

When I do this in the calculator I get the correct price. When I did this in Caspio Cloud, it also worked. So my problem is just how to put in all the () and , and â€śâ€ť or {} at the right places for this!

If someone have the time to read and look trough this I would be really happy

Thank you
Andreas.

Hi there,

Squiggly brackets â€ś{}â€ť go around field names. You donâ€™t need them for a field name that only has one word and no special characters, but I like to use them for all field names so theyâ€™re easily recognizable.

Parentheses â€ś()â€ť are used as part of the formula function, either to wrap the entire function, or perform certain operations first in mathematical calculations.

So, for your example with 29 days, I would write the formula like thisâ€¦

``````IF({Dager} > 21, SUM((({Dager} - 21)*20), 1490))
``````

Hope that helps!

Thank you for such a fast answer! Now I understand a litte bit more, and the formula you provided is working perfect!

Again thank you very much, I really appreciate it!

1 Like
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}