How to increase a date in a script

Viewing 2 reply threads
  • Author
    Posts
  • April 21, 2023 at 10:39 AM #49371

    Victor Warner
    Participant

    In a document I have a date field which is referenced such has

    var date_of_notarial_act_id = 'fld-76fd68bf708e4bde87998a0cba32ffcd';
    var date_of_notarial_act = record.getFieldValue('fld-76fd68bf708e4bde87998a0cba32ffcd');

    but I would like to add 5 days to it and then that new date written to another form. Doing something such as:

    var write_up_notarial_register_date = date_of_notarial_act + 5;

    Does not work. Is what I would like to do possible with JavaScript in Tap Forms?

    Any help would be gratefully appreciated.

    April 21, 2023 at 2:56 PM #49372

    Daniel Leu
    Participant

    The easiest I think would be to use a calculation field instead of a script field: DATEADD([date_of_notarial_act];0;0;0;5;0;0;0).

    Or in Javascript

    // Create date object
    let write_up_notarial_register_date = new Date(date_of_notarial_act);
    
    // Add five days to current date
    write_up_notarial_register_date.setDate(write_up_notarial_register_date.getDate() + 5);
    April 22, 2023 at 4:51 AM #49375

    Victor Warner
    Participant

    Daniel,

    Thank you for the information.

    It has to be in JavaScript as is needed for use within a longer script.

Viewing 2 reply threads

You must be logged in to reply to this topic.