Skip to main content
Participant
August 12, 2022
Question

How to separate the dates?

  • August 12, 2022
  • 1 reply
  • 107 views

Hello,
Please help to solve this problem.
I have a set a text field date "13 September 2022" in page 1.

I need to seperate the DD and the MMMMYYYY in another page.

E.g. 13 day of September 2022, display in page 4


Can anyone help me?
Please do help write the full explanation & Javascript needed, as I am totally not good in Javascript.
Direct answer, will be better.

Thank you.

    This topic has been closed for replies.

    1 reply

    Lilybiri
    Legend
    August 12, 2022

    This is clearly not a date from the system variables, since it is a future date. I suspect you just typed it in (caption or shape) or is it captured from the learner in a Text Entry Box? It is necessary to have the text in a variable, which would automatically be the case in the second scenario (TEB) but not in the first. 

    I'll wait for your answer before trying an explanation.

    Participant
    August 15, 2022

    Hi LilyBiri,
    Thank you for your reply.

    text field date 
    "13 September 2022" in page 1.
    I have made some changes for the date field (id: Insert Date). It will be as Enter Date "Filled in".

    In this Insert Date, I key in below script  in (Format > Custom Format Script 😞

    var date = value.getDate();
    this.getField("Insert Date-dd").value = date;

    var month = months[value.getMonth()];
    var year = value.getFullYear();

    this.getField("Insert Date-mmyy").value = month + " " + year;


    I need to seperate the DD and the MMMMYYYY in another page.
    ie: 13 day of September 2022, display in page 4

    Below is the script (For Date - 13, id: Insert Date-dd) in (Format > Custom Format Script ):: 

    var insert = this.getField("Insert Date").value;
    var value = util.scand("d mmmm yyyy", insert);

    this.getField("Insert Date-dd").value = value.getDate();

    Below is the script (For MMMMYYYY - September 2022, id: Insert Date-mmyy) in (Format > Custom Format Script 😞 

    var insert = this.getField("Insert Date").value;
    var value = util.scand("d mmmm yyyy", insert);

    const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

    this.getField("Insert Date-mmyy").value = months[value.getMonth()] + " " + value.getFullYear();


    These are the script that i tried, but its not showing the same Date, as keyed in.
    Month and Year is OK,

    but if lets say, we were to change the date:
    Date, Month and Year, all will not change accordingly.

    Please advice, if there is any error in the script.
    TQ

    Participant
    August 16, 2022

    Hi LilyBiri,
    The problem is solved.

    Thank you for your assist.