Title: IF conditional with dates
Last modified: July 29, 2020

---

# IF conditional with dates

 *  Resolved [drteddy](https://wordpress.org/support/users/drteddy/)
 * (@drteddy)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/if-conditional-with-dates/)
 * 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](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/if-conditional-with-dates/#post-13184854)
 * Hello [@drteddy](https://wordpress.org/support/users/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](https://cff.dwbooster.com/customization)
 * Best regards.

Viewing 1 replies (of 1 total)

The topic ‘IF conditional with dates’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

## Tags

 * [dates](https://wordpress.org/support/topic-tag/dates/)

 * 1 reply
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/if-conditional-with-dates/#post-13184854)
 * Status: resolved