Hello @kjou06
Thank you very much for using our plugin. Assuming the date field is the fieldname123, you can insert a calculated field in the form and enter the equation:
(function(){
let d = CDATE(fieldname123, 'yyyy/mm/dd');
if (d<='2025/04/30') return 200;
if (d<='2025/06/30') return 140;
return 110;
})()
You need only to replace fieldname123 in the previous equation with the name of the date field in your form.
Best regards.
Thread Starter
kjou06
(@kjou06)
Thanks for the super fast reply but it doesn’t work because the calculation field would have to detect if the current date is between two dates.
In your equation,
(function(){
let d = CDATE(fieldname123, ‘yyyy/mm/dd’);
if (d<=’2025/04/30′) return 200; if (d<=’2025/06/30′) return 140; return 110; })() the rate remains the same if the date <= 2025/04/30 or <= 2025/06/30 since the equation does not calculate if the date is >= 2025/30/04 AND <= 2025/30/06
Hello @kjou06
I’m sorry, but what you say is incorrect. The use of return instruction stops the evaluation of the equation returning a result, the other lines in the equation are not evaluated.
If the following condition is satisfied
if (d<='2025/04/30') return 200;
The equation returns 200 and the second condition is never reached.
Have you tested the equation?
Best regards.
Thread Starter
kjou06
(@kjou06)
Sorry. It actually works fine with the yyyy/mm/dd date format but if my date field is formatted in dd/mm/yyyy, it doesn’t work anymore
Hello @kjou06
You are describing a different situation. The code I recommended previously is based on your initial question, where is feasible to compare them alphabetically. But if you change the date format, you cannot compare them as texts and must convert them into date objects. In this case, the equation would be:
(function(){
let d = DATEOBJ(fieldname123, 'dd/mm/yyyy');
if (d<=DATEOBJ('30/04/2025', 'dd/mm/yyyy')) return 200;
if (d<=DATEOBJ('30/06/2025', 'dd/mm/yyyy')) return 140;
return 110;
})()
Best regards.
Thread Starter
kjou06
(@kjou06)
Thank you very much. It’s perfect