• Resolved drteddy

    (@drteddy)


    Hi!

    I have a form with a field that calculates the costs for a conference attendees.

    The cost is calculated according to two fields: date of registration and profession.
    An example:

    • If the user is registering before a specific date AND he/she is a student the fees are X euros.
    • If the user is registering before a specific date AND he/she is a professor the fees are Y euros.
    • If the user is registering before a specific date AND he/she is a another thing the fees are 0 euros.

    I tried with IF(fieldname3<=’30/10/2020′,fieldname4,fieldname4+20) but it didn’t work. Fieldname3 is a date field, fieldname4 is a dropdown field.

    Any help appreciated.
    Thanks in advance

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

    (@codepeople)

    Hello @drteddy

    No, you cannot compare date fields with texts with date format. These are different types of data. You should transform one of them into the format of the other before comparing them.

    I’ll try to describe the process with a hypothetical example.

    Assuming the date field is the fieldname3, and the fieldname2 is a radio button with three choices: student, professor, other (javascript is a case sensitive programming language), and the date to compare is: 2020/10/30 (I’m using the text for a date with the format: “yyyy/mm/dd” to avoid ambiguity)

    The equation associated to the calculated field would be similar to:

    
    (function(){
    var d = CDATE(fieldname3, 'yyyy/mm/dd'), result = fieldname4, increment = 0;
    
    if(fieldname2 == 'student' && d < '2020/10/30') increment = 20;
    else if(fieldname2 == 'professor' && d < '2020/10/30') increment = 40;
    else if(d < '2020/10/30') increment = 50;
    
    return result+increment;
    })()
    

    Of course, my example is hypothetical. You should use the correct values, dates, and fields’ names.

    The support service does not cover the implementation of the users’ projects (forms or formulas). If you need additional support to implement your project, you can contact me through my private website: Customization

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘IF conditional with dates’ is closed to new replies.