Skip to main content
Participant
Aug 12, 2022 5:32 AM UTC
Question

How to separate the dates?

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 is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    Lilybiri
    Legend
    Aug 12, 2022 3:30 PM UTC

    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.

    Translate
    Participant
    Aug 15, 2022 6:58 AM UTC

    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

    Translate
    Participant
    Aug 16, 2022 3:11 AM UTC

    Hi LilyBiri,
    The problem is solved.

    Thank you for your assist.

    Translate