• Resolved itzikn

    (@itzikn)


    I have 2 date input field and i want to init the first as first date of current month and year, and the 2nd as last date of current and year.

    I can set the fields by html but the automatic calculation for other field not done.

    Any help ?

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

    (@codepeople)

    Hello @itzikn,

    Thank you very much for using our plugin. I’ll try to describe the process with a hypothetical example. Assuming the date fields are fieldname1 and fieldname2, respectively, and their date format is mm/dd/yyyy.

    Insert a calculated field in the form and enter the following piece of code as its equation (The calculated field can be hidden by ticking a checkbox in its settings):

    
    (function(){
    let first = TODAY(),
    last = EOMONTH(TODAY());
    
    first.setDate(1);
    
    getField(fieldname1|n).setVal(GETDATETIMESTRING(first, 'mm/dd/yyyy'));
    
    getField(fieldname2|n).setVal(GETDATETIMESTRING(last, 'mm/dd/yyyy'));
    
    })()

    There are other alternatives. For example, the following equation is equivalent to the previous one:

    (function(){
    let first = MONTH()+'/1/'+YEAR(),
    last = MONTH()+'/'+DAY(EOMONTH(TODAY()))+'/'+YEAR();
    
    getField(fieldname1|n).setVal(first);
    
    getField(fieldname2|n).setVal(last);
    
    })()

    Best regards.

    Thread Starter itzikn

    (@itzikn)

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Predefine date’ is closed to new replies.