• Resolved fibbu

    (@fibbu)


    Hello;
    I wrote the following code to calculate the 1st date and set the years automatically.

    date1 : fieldname14 selected date

    date2 : fieldname15 it gets 30/09/YEAR every year.

    (function() {
      var current_year = YEAR(TODAY());
      var first_day_year = '30/09/' + current_year;
    
      jQuery('#calculation-first_day_year').html(first_day_year);
      jQuery('.kriter1-aciklama').html('Ba?lang?? Hesaplama : ');
      jQuery('.kriter1-sonuc').html(GETDATETIMESTRING(first_day_year, 'dd/mm/yyyy'), 'dd/mm/yyyy');
    })();

    I get the selected date automatically in the 2nd date.

    Master calculation code;

    (function() {
      var ay = DATEDIFF(fieldname15, fieldname14, 'dd/mm/yyyy', 'y')['months'];
    
      jQuery('#calculation-ay').html(ay);
      jQuery('.kriter2-aciklama').html('ABC: ');
      jQuery('.kriter2-sonuc').html('<span style="color: orange;">' + ay + '</span>');
    
      return ay;
    })();

    where am i doing wrong?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @fibbu

    Your first equation needs a return statement to assign the calculated date to the field. Otherwise, the calculated field will remain empty:

    (function() {
      var current_year = YEAR(TODAY());
      var first_day_year = '30/09/' + current_year;
    
      jQuery('#calculation-first_day_year').html(first_day_year);
      jQuery('.kriter1-aciklama').html('Ba?lang?? Hesaplama : ');
      jQuery('.kriter1-sonuc').html(GETDATETIMESTRING(first_day_year, 'dd/mm/yyyy'), 'dd/mm/yyyy');
    
    return first_day_year;
    })();

    Thread Starter fibbu

    (@fibbu)

    Could there be a problem with the code you sent?

    additionally is the second main calculation equation correct?
    so filedname 15-fieldname 14 needs to output date and write month number.

    Plugin Author codepeople

    (@codepeople)

    Hello @fibbu

    This line of code is incorrect:

    jQuery('.kriter1-sonuc').html(GETDATETIMESTRING(first_day_year, 'dd/mm/yyyy'), 'dd/mm/yyyy');

    The correct is simply:

    jQuery('.kriter1-sonuc').html(first_day_year);

    If you have any other question, please, indicate the link to the page that contains the form to check your equations in action.

    Best regardss.

    Thread Starter fibbu

    (@fibbu)

    thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Two date calculation problems’ is closed to new replies.