• Resolved 4kez

    (@4kez)


    Hello
    I’m new here and I found your plugin amazing

    can you tell me please how to make this Calculation with Dates?

    if the check in to check-out days are from 1day to 14days the price is 0
    if the check in to check-out days are from 15days to 90days the price is 1500
    if the check-in to check-out days are from 181days to 270days the price is 2500
    if the check-in to check-out days are from 271days to 360days the price is 3000
    if the check in to check-out days are from 361days to 450days the price is 3500
    if the check-in to check-out days are from 451days to 540days the price is 4000
    if the check-in to check-out days are from 541days to 630days the price is 4500
    if the check in to check-out days are from 631days to 720days the price is 5000
    if the check-in to check-out days are from 721days to 810days the price is 5500
    if the check-in to check-out days are from 811days to 900days the price is 6000

    thank you so much

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @4kez

    If you have two Date fields, for example, fieldname1 and fieldname2, and you want to get the days between them, you should use the piece of code: ABS(fieldname1-fieldname2)

    Furthermore, if the price is determined by the number of days, you should use conditional statements in the equation. The equation associated with the calculated field would be similar to:

    
    (function(){
    var d = ABS(fieldname1-fieldname2);
    if(d <= 14) return 0;
    if(d <= 90) return 1500;
    if(d <= 270) return 2500;
    if(d <= 360) return 3000;
    if(d <= 450) return 3500;
    if(d <= 540) return 4000;
    if(d <= 630) return 4500;
    if(d <= 720) return 5000;
    if(d <= 810) return 5500;
    return 6000;
    })()
    

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘how to calculate days with different prices’ is closed to new replies.