[ad_1]
Hello @garteth
I’ll try to describe the process with a hypothetical example.
Assuming you are referring to the prices per day and fieldname1 and fieldname2 are date fields for check-in and check-out, respectively.
You can calculate the final price day to day by implementing the equation entered in the calculated field as follows:
(function(){
var price_month = {1:20, 2:20, 3:20, 4:40, 5:40, 6:40, 7:60, 8:60, 9:60, 10:80, 11:80, 12:90},
check_in = MIN(fieldname1, fieldname2),
check_out = MAX(fieldname1, fieldname2),
price = 0;
while(check_in <= check_out){
price += price_month[MONTH(check_in)];
check_in++;
}
return price;
})()And that’s all.
Best regards.
