• Resolved klingbeil

    (@klingbeil)


    Hi

    fieldname 14 : Start Date
    fieldname 15 : End Date
    It 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?

    (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)
  • Plugin Author codepeople

    (@codepeople)

    Hello @klingbeil,

    To display an error message when fieldname15 < fieldname14 you can include an “if” conditional statement in the equation:

    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:

    NETWORKDAYS(fieldname1, fieldname1+fieldname2, "dd/mm/yyyy");

    Best regards.

    Thread Starter klingbeil

    (@klingbeil)

    I explain the second question as follows.
    For example: User selected date.
    fieldname25 : 01/01/2023
    then 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

    (@codepeople)

    Hello @klingbeil,

    In this case, you only should pass the ignore weekend parameter to the DATETIMESUM operation (https://cff.dwbooster.com/documentation#datetime-module)

    GETDATETIMESTRING(DATETIMESUM('01/01/2023', 'dd/mm/yyyy', 5, 'd', true), 'dd/mm/yyyy');

    Best regards.

    Thread Starter klingbeil

    (@klingbeil)

    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/2023
    29/11/2023
    30/11/2023
    01/12/2023 (+5 work day)

    You sample: 24/11/2023 + 5 DAYS
    25/11/2023
    26/11/2023
    27/11/2023
    28/11/2023
    29/11/2023

    Thanks

    • This reply was modified 1 year ago by klingbeil.
    Plugin Author codepeople

    (@codepeople)

    Hello @klingbeil,

    With my recommended code the solution is correct. Please look at the screenshot image below:

    Best regards.

    Thread Starter klingbeil

    (@klingbeil)

    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.

    (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

    (@codepeople)

    Hello @klingbeil,

    You only should edit the following piece of code:

     
    var kriter3;
    if (fieldname23 === 'A' && fieldname26 === 'Z') {  

    As below:

     
    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

    (@klingbeil)


    • This reply was modified 1 year ago by klingbeil.
    Thread Starter klingbeil

    (@klingbeil)

    I solved it, thank you for your patience.

    Thread Starter klingbeil

    (@klingbeil)

    Hello;
    How can we bring the current year to the end of history?

      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

    (@codepeople)

    Hello @klingbeil

    You should use the YEAR() operation

     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

    (@klingbeil)

    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.

    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

    (@codepeople)

    Hello @codepeople

    Yes, I’m sorry. I simply copied your previous code and included the parenthesis to YEAR.

    The correct is:

    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

    (@klingbeil)

    No problem, it worked, thank you very much.

    Thread Starter klingbeil

    (@klingbeil)

    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 1 year ago by klingbeil.
Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Date Problem Formule’ is closed to new replies.