Title: Date Problem Formule
Last modified: November 24, 2023

---

# Date Problem Formule

 *  Resolved [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/)
 * Hi
 * fieldname 14 : Start Date
   fieldname 15 : End DateIt expresses.My 1st question
   = Printing error message if fieldname 14 field is greater than fieldname 15 field.
   My 2nd question: How do we calculate business days NETWORKDAYS by adding the 
   number of days from the start date (fieldname24) to the criterion = (fieldname
   23 === ‘B’)?Can you help me complete the formula?
 *     ```wp-block-code
       (function() {
         var kriter3;
         if (DATEOBJ(fieldname14, 'dd/mm/yyyy').getTime() > DATEOBJ(fieldname15, 'dd/mm/yyyy').getTime()) {  
           jQuery('#calculation-kriter3').html('Seçilen tarih ileri bir tarihdir.');
           return 'Seçilen tarih ileri bir tarihdir.';
         } else {
         if (fieldname23 === 'A') {  
           kriter3 = NETWORKDAYS(fieldname15, fieldname14, "dd/mm/yyyy");
           jQuery('#calculation-kriter3').html(kriter3);
           jQuery('.kriter3-aciklama').html('İş Günü Sayısı : ');
           jQuery('.kriter3-sonuc').html(kriter3 + ' gün');
   
         } 
         if (fieldname23 === 'B') {
           kriter3 = DATETIMESUM(fieldname14, 'dd/mm/yyyy', fieldname24, 'd');
           jQuery('#calculation-kriter3').html(kriter3);
           jQuery('.kriter3-aciklama').html('İş Günü Sonrası Tarih : ');
           jQuery('.kriter3-sonuc').html(kriter3);
         } 
   
         return [kriter3];
       })();
       ```
   

Viewing 15 replies - 1 through 15 (of 23 total)

1 [2](https://wordpress.org/support/topic/date-problem-formule/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/date-problem-formule/page/2/?output_format=md)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17226703)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/),
 * To display an error message when fieldname15 < fieldname14 you can include an“
   if” conditional statement in the equation:
 *     ```wp-block-code
       if(fieldname15<fieldname4) return 'Error message here';
       ```
   
 * I’m not sure about your question
 * However, if you have a date field, for example, fieldname1, and you want to sum
   a number of days, fieldname2, and calculate the network days between fieldname1
   and the result of fieldname1+fieldname2, you can enter the following piece of
   code:
 *     ```wp-block-code
       NETWORKDAYS(fieldname1, fieldname1+fieldname2, "dd/mm/yyyy");
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17226750)
 * I explain the second question as follows.
   For example: User selected date.fieldname25:
   01/01/2023then the user added +5 days to the number field (fieldname24).
 * The criterion here is 01/01/2023 + 5 days. It will write the date by counting
   5 business days after 01/01/2023.
   Thanks.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17226777)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/),
 * In this case, you only should pass the ignore weekend parameter to the DATETIMESUM
   operation ([https://cff.dwbooster.com/documentation#datetime-module](https://cff.dwbooster.com/documentation#datetime-module))
 *     ```wp-block-code
       GETDATETIMESTRING(DATETIMESUM('01/01/2023', 'dd/mm/yyyy', 5, 'd', true), 'dd/mm/yyyy');
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17226792)
 * This already works, my formula is correct. When we add +5 days, I want it to 
   count as the number of days (WORKING DAYS).
   Sample: 24/11/2023 + 5 work day
 * 27/11/2023
   28/11/202329/11/202330/11/202301/12/2023 (+5 work day)
 * You sample: 24/11/2023 + 5 DAYS
   25/11/202326/11/202327/11/202328/11/202329/11/
   2023
 * Thanks
    -  This reply was modified 2 years, 6 months ago by [klingbeil](https://wordpress.org/support/users/klingbeil/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17226842)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/),
 * With my recommended code the solution is correct. Please look at the screenshot
   image below:
 * ![](https://i0.wp.com/resources.developers4web.com/cff/tmp/2023/11/23/brave_s42UxNqjlq.
   png?ssl=1)
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17226995)
 * First of all, thank you for your understanding. Our code worked, but the error
   message was that our code did not work.
 * fieldname15 : Start date
   fieldname25 : End Date
 * Regardless of CriterionA or B, I cannot write an error message to the criterion3
   result in the fieldname15>fieldname25 field.
   Thanks.
 *     ```wp-block-code
       (function() {
         var kriter3;
         if (fieldname23 === 'A' && fieldname26 === 'Z') {  
           kriter3 = NETWORKDAYS(fieldname15, fieldname25, "dd/mm/yyyy");
           jQuery('#calculation-kriter3').html(kriter3);
           jQuery('.kriter3-aciklama').html('İş Günü Sayısı : ');
           jQuery('.kriter3-sonuc').html(kriter3 + ' gün');
         } else if (fieldname23 === 'A') {  
           kriter3 = NETWORKDAYS(fieldname15, fieldname25, "dd/mm/yyyy") - 1;
           jQuery('#calculation-kriter3').html(kriter3);
           jQuery('.kriter3-aciklama').html('İş Günü Sayısı : ');
           jQuery('.kriter3-sonuc').html(kriter3 + ' gün');
         } else if (fieldname23 === 'B') {  
           kriter3 = GETDATETIMESTRING(DATETIMESUM(fieldname25, 'dd/mm/yyyy', fieldname24-1, 'd', true), 'dd/mm/yyyy');
           jQuery('#calculation-kriter3').html(kriter3);
           jQuery('.kriter3-aciklama').html('İş Günü Tarihi : ');
           jQuery('.kriter3-sonuc').html(kriter3);
         } 
   
         return [kriter3];
   
       })();
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17227053)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/),
 * You only should edit the following piece of code:
 *     ```wp-block-code
       var kriter3;
       if (fieldname23 === 'A' && fieldname26 === 'Z') {  
       ```
   
 * As below:
 *     ```wp-block-code
       var kriter3;
       if(fieldname25<fieldname15){
           jQuery('.kriter3-sonuc').html('Your error message');
           return 'Your error message';
       }
       if (fieldname23 === 'A' && fieldname26 === 'Z') {  
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17227106)
 * …
    -  This reply was modified 2 years, 6 months ago by [klingbeil](https://wordpress.org/support/users/klingbeil/).
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17227143)
 * **I solved it, thank you for your patience.**
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17228560)
 * Hello;
   How can we bring the current year to the end of history?
 *     ```wp-block-code
         kriter3 = NETWORKDAYS(fieldname25, fieldname15, "dd/mm/yyyy", ["02/01/'+YEAR+'", "03/01/'+YEAR+'", "04/01/'+YEAR+'", "05/01/'+YEAR+'"], "dd/mm/yyyy");
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17228713)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/)
 * You should use the YEAR() operation
 *     ```wp-block-code
        kriter3 = NETWORKDAYS(fieldname25, fieldname15, "dd/mm/yyyy", ["02/01/'+YEAR()+'", "03/01/'+YEAR()+'", "04/01/'+YEAR()+'", "05/01/'+YEAR()+'"], "dd/mm/yyyy");
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17228817)
 * I think there is a problem with the code you provided.
 * It works as I shared below. But when I add what you gave it doesn’t work.
 *     ```wp-block-code
       kriter3 = NETWORKDAYS(fieldname15, fieldname25, "dd/mm/yyyy", ["01/01/2023", "02/01/2023", "03/01/2023", "04/01/2023", "05/01/2023", "06/01/2023"], "dd/mm/yyyy");
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17228868)
 * Hello [@codepeople](https://wordpress.org/support/users/codepeople/)
 * Yes, I’m sorry. I simply copied your previous code and included the parenthesis
   to YEAR.
 * The correct is:
 *     ```wp-block-code
       kriter3 = NETWORKDAYS(fieldname25, fieldname15, "dd/mm/yyyy", ["02/01/"+YEAR(), "03/01/"+YEAR(), "04/01/"+YEAR(), "05/01/"+YEAR()], "dd/mm/yyyy");
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17228875)
 * No problem, it worked, thank you very much.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/#post-17230036)
 * Hello, the days between 2 dates; (20-23 Apr
   Is it possible to display the day
   names like this (Thu, Fri, Sat, Sun,)?Thanks.
    -  This reply was modified 2 years, 6 months ago by [klingbeil](https://wordpress.org/support/users/klingbeil/).

Viewing 15 replies - 1 through 15 (of 23 total)

1 [2](https://wordpress.org/support/topic/date-problem-formule/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/date-problem-formule/page/2/?output_format=md)

The topic ‘Date Problem Formule’ 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/)

 * 23 replies
 * 2 participants
 * Last reply from: [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/date-problem-formule/page/2/#post-17230580)
 * Status: resolved