Title: Date error
Last modified: May 13, 2023

---

# Date error

 *  Resolved [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/date-error-10/)
 * Hello;
   The result I got in my previous operation is in the form of date. I am
   trying to extract a number value that I calculated from this result date.My calculation
   function is as follows.
 *     ```wp-block-code
       (function(){
         var bedelliterhistarihi, kisadonemterhistarihi, uzundonemterhistarihi;
          if (fieldname14 == 'A') {
           bedelliterhistarihi = CDATE((fieldname23+5),'dd/mm/yyyy');
           jQuery('#calculation-bedelliterhistarihi').html(bedelliterhistarihi);
           jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
           jQuery('.askerlikterhistarihi-sonuc').html(bedelliterhistarihi);
         }
         if (fieldname14 == 'B') {
           kisadonemterhistarihi = CDATE((fieldname23+5),'dd/mm/yyyy');
           jQuery('#calculation-kisadonemterhistarihi').html(kisadonemterhistarihi);
           jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
           jQuery('.askerlikterhistarihi-sonuc').html(kisadonemterhistarihi);
         }
         if (fieldname14 == 'C') {
           uzundonemterhistarihi = CDATE((fieldname23+5),'dd/mm/yyyy');
           jQuery('#calculation-uzundonemterhistarihi').html(uzundonemterhistarihi);
           jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
           jQuery('.askerlikterhistarihi-sonuc').html(uzundonemterhistarihi);
         }
   
         return [bedelliterhistarihi, kisadonemterhistarihi, uzundonemterhistarihi];
       })();
       ```
   
 * Screen Result : **,01/11/2023,5**
 * brings in the form.
   Where am I doing wrong?
 * Thanks
    -  This topic was modified 3 years, 1 month ago by [klingbeil](https://wordpress.org/support/users/klingbeil/).

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/date-error-10/#post-16734614)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/)
 * The code snippet below returns the variables’ values concatenated with comma 
   symbols. But as you define the variables into conditionals, some of them are 
   empties:
 *     ```wp-block-code
       return [bedelliterhistarihi, kisadonemterhistarihi, uzundonemterhistarihi];
       ```
   
 * The correct would be to include separated `return` instructions.
 *     ```wp-block-code
       (function () {
           var bedelliterhistarihi,
           kisadonemterhistarihi,
           uzundonemterhistarihi;
           if (fieldname14 == 'A') {
               bedelliterhistarihi = CDATE((fieldname23 + 5), 'dd/mm/yyyy');
               jQuery('#calculation-bedelliterhistarihi').html(bedelliterhistarihi);
               jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
               jQuery('.askerlikterhistarihi-sonuc').html(bedelliterhistarihi);
       		return bedelliterhistarihi;
           }
           if (fieldname14 == 'B') {
               kisadonemterhistarihi = CDATE((fieldname23 + 5), 'dd/mm/yyyy');
               jQuery('#calculation-kisadonemterhistarihi').html(kisadonemterhistarihi);
               jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
               jQuery('.askerlikterhistarihi-sonuc').html(kisadonemterhistarihi);
       		return kisadonemterhistarihi;
           }
           if (fieldname14 == 'C') {
               uzundonemterhistarihi = CDATE((fieldname23 + 5), 'dd/mm/yyyy');
               jQuery('#calculation-uzundonemterhistarihi').html(uzundonemterhistarihi);
               jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
               jQuery('.askerlikterhistarihi-sonuc').html(uzundonemterhistarihi);
       		return uzundonemterhistarihi;
           }
   
           return '';
       })();
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/date-error-10/#post-16734874)
 * Hello,
   I did as you said and added the number to be collected at the end, this
   time it didn’t add it on the date, it just wrote it next to it.
 * **01/11/20235**
 * **01/11/2023**(5)
 *     ```wp-block-code
           if (fieldname14 == 'A') {
               bedelliterhistarihi = CDATE((fieldname23 + 5), 'dd/mm/yyyy');
               jQuery('#calculation-bedelliterhistarihi').html(bedelliterhistarihi);
               jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
               jQuery('.askerlikterhistarihi-sonuc').html(bedelliterhistarihi);
       		return bedelliterhistarihi;
           }
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/date-error-10/#post-16734901)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/)
 * Which is the control type of the fieldname23 field? If it is not a date field,
   but a text with date format (dd/mm/yyyy), the correct would be to use the DATETIMESUM
   and GETDATETIMESTRING operations:
 *     ```wp-block-code
       bedelliterhistarihi = GETDATETIMESTRING(DATETIMESUM(fieldname23, 'dd/mm/yyyy', 5, 'd'), 'dd/mm/yyyy');
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16752175)
 * Hello. I am adding and subtracting time by entering the year month day week value
   on the date. There is no problem with the calculation process. But I am trying
   to print the numbers entered by the user on the time:result screen. For example:
   If the user entered 1 Year 4 Weeks Duration : Side by side 1 Year 4 Weeks will
   be written in this field. If he fills and empties one of these fields while calculating
   again, it will write the current value again. How to do this, I’ve been struggling
   since morning.
 * [Link:](https://www.pexpe.com/tarih-hesaplama/)
 *     ```wp-block-code
       var result = '';
       var eklenensure = '';
   
       if (fieldname19) {
         eklenensure = fieldname19;
         result += eklenensure + ' Yıl';
       }
   
       if (fieldname20) {
         eklenensure = fieldname20;
         if (result !== '') {
           result += ' ';
         }
         result += eklenensure + ' Ay';
       }
   
       if (fieldname21) {
         eklenensure = fieldname21;
         if (result !== '') {
           result += ' ';
         }
         result += eklenensure + ' Hafta';
       }
   
       if (fieldname22) {
         eklenensure = fieldname22;
         if (result !== '') {
           result += ' ';
         }
         result += eklenensure + ' Gün';
       }
   
       // Güncel değerleri hesaplamak için sıfırlama yap
       jQuery('#fieldname19').val('');
       jQuery('#fieldname20').val('');
       jQuery('#fieldname21').val('');
       jQuery('#fieldname22').val('');
   
       if (result.trim() === '') {
         jQuery('#calculation-eklenensure').empty().hide();
       } else {
         jQuery('#calculation-eklenensure').html(result).show();
       }
   
       return eklenensure;
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16752269)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/)
 * The plugin replaces the fields’ names with their corresponding values before 
   evaluating the equations to use them in mathematical operations. To refer to 
   the fields’ names directly, you must use the |n modifier (Ex. fieldname19|n).
   Additionally, if you want to assign a value to a field, it is preferred to use
   the plugin operations. And finally, since the plugin minifies the equations’ 
   code, you should not use comments with single-line structure (//…). Please, enter
   comments in block format instead (/* … */)
 * The equation would be:
 *     ```wp-block-code
       (function(){
       var result = [],
           eklenensure = '';
   
       if (fieldname19) {
         eklenensure = fieldname19;
         result.push(eklenensure + ' Yıl');
       }
   
       if (fieldname20) {
         eklenensure = fieldname20;
         result.push(eklenensure + ' Ay');
       }
   
       if (fieldname21) {
         eklenensure = fieldname21;
         result.push(eklenensure + ' Hafta');
       }
   
       if (fieldname22) {
         eklenensure = fieldname22;
         result.push(eklenensure + ' Gün');
       }
   
       /* Güncel değerleri hesaplamak için sıfırlama yap */
       getField(fieldname19|n).setVal('', true);
       getField(fieldname20|n).setVal('', true);
       getField(fieldname21|n).setVal('', true);
       getField(fieldname22|n).setVal('', true);
   
       jQuery('#calculation-eklenensure').html(result.join(' '))[IF(result.length, 'show', 'hide')]();
   
       return eklenensure;
       })()
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16752284)
 * ok i got it thanks a lot
    -  This reply was modified 3 years ago by [klingbeil](https://wordpress.org/support/users/klingbeil/).
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16754840)
 * Hello,
   I print the result as a date as much as the value entered on the code 
   at the bottom.For example, the user chose the date : 21/05/2023 and wrote 5 days
   on it.Date : fieldname17Value : fieldname27
 * My question is; I am now printing the date as much as the entered value, but 
   how do I print 12 times forward in the same way?
 * Example :
   1st value 21/05/20232nd value 26/05/20233rd value 31/05/2023
 * I want to calculate the result of 12 values as the value written in the form 
   forward.
   Thanks.
 *     ```wp-block-code
       (function(){
       var adetsure = GETDATETIMESTRING(DATETIMESUM(fieldname17, 'dd/mm/yyyy', fieldname27, 'd'), 'dd/mm/yyyy');
       jQuery('#calculation-adetsure').html(adetsure);
       return adetsure;
       })()
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16755004)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/)
 * You can implement the equation as follows:
 *     ```wp-block-code
       (function () {
           var adetsure = []; 
       	for(let i = 1; i <= 12; i++){
       		adetsure.push( GETDATETIMESTRING(DATETIMESUM(fieldname17, 'dd/mm/yyyy', fieldname27*i, 'd'), 'dd/mm/yyyy') );
       	}
       	adetsure = adetsure.join('<br>');
           jQuery('#calculation-adetsure').html(adetsure);
           return adetsure;
       })()
       ```
   
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16755263)
 * I’m having a bit of a hard time switching to the new method, but it’s my last
   form page.
   fieldname38 : Today Dated: Selected DateI am trying to find the number
   of days by subtracting it from the date, where is the error, I am getting blank
   results.
 *     ```wp-block-code
       (function(){
       var d = CONCATENATE(fieldname33,'/', fieldname34, '/', fieldname35);
         var toplamgunfarki= ABS(fieldname38 - d);
         jQuery('#calculation-toplamgunfarki').html(toplamgunfarki + ' Gün');
         return toplamgunfarki;
       })();
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16755661)
 * Hello [@klingbeil](https://wordpress.org/support/users/klingbeil/)
 * You can use directly ABS(fieldname38 – d); only if both operands are date fields
   or numbers. But in your equation, the “d” operand contains a text with date format.
   In this case, you must use the DATEDIFF operation:
 *     ```wp-block-code
       var toplamgunfarki= DATEDIFF(fieldname38, d, 'dd/mm/yyyy', 'd')['days'];
       ```
   
 * Please, read the date/time operations module by visiting the following link:
 * [https://cff.dwbooster.com/documentation#datetime-module](https://cff.dwbooster.com/documentation#datetime-module)
 * Best regards.
 *  Thread Starter [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * (@klingbeil)
 * [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16755691)
 * Thank you very much for your support. You patiently answer all of our questions.

Viewing 11 replies - 1 through 11 (of 11 total)

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

 * 11 replies
 * 2 participants
 * Last reply from: [klingbeil](https://wordpress.org/support/users/klingbeil/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/date-error-10/#post-16755691)
 * Status: resolved