Hello @monika999,
In this case, you must walk the days from checking to checkout and summing the corresponding amounts.
For example, assuming you have two date fields for the checking and checkout. I’ll call the fieldname1 and fieldname2, and you want to sum their corresponding prices, including the first and last days.
You can insert a calculate field in the form and enter the equation:
(function(){
var prices_list = {
1:80,
2:60,
3:70,
4:50,
5:50,
6:60,
7:40
},
d1 = DATEOBJ(MIN(fieldname1,fieldname2)),
d2 = DATEOBJ(MAX(fieldname1,fieldname2)),
result = 0;
while(d1<=d2){
result += prices_list(WEEKDAY(d1));
d1.setDate(d1.getDate()+1);
}
return PREC(result,2);
})()
And that’s all.
Best regards.
Hi. Thanks for the quick reply. That’s not exactly what I had in mind. The idea is that after selecting a given day from the calendar (su, Mo..), the final result will display the number (price) assigned to it.
Hello @@monika999
In this case, the process is simpler. Assuming the date field is the fieldname1, the equation in the calculated field would be:
({1:80,2:60,3:70,4:50,5:50,6:60,7:40})[WEEKDAY(fieldname1)]
Best regards.
You are amazing. Thanks. What if we took into account that until 4 p.m. the price = 60, and after 4 p.m. the price = 80 every day??? Thank you for your help:)
Hello @monika999
In that case, you must use operations like HOURS and include conditional statements as part of the equation. Learn more about the Date/Time operations module by reading the following section in the plugin documentation:
https://cff.dwbooster.com/documentation#datetime-module
If you require assistance implementing your equations, please contact us through the plugin website.
Best regards.