Forum Discussion

EmmaGraham's avatar
EmmaGraham
Community Member
2 years ago

Is it possible to have an automatic adjusted date based on the current system date

Hi Team, I only get to use SL a few times per year so what I'm asking may be a simple fix.

I have created a basic activity where the leaner needs to look at an expiry date shown (the expiry date is currently a screenshot from our live system). If it is within 60 days of the expiry date they will select "process the transaction". If the date is more than 60 days ago, the learner selects the "transfer" option. Currently I have a statement on screen "for the purpose of this exercise todays date is the 20/03/22", this is necessary so that in 6mths time when the activity is completed by new team members the answers are still correct.

Is there a way I can have a date display that is always +/- 4wks of the current date, it adjust automatically to whatever the system date is? This would allow me to remove the the date statement which is super primitive. It also means that unless there is a legislative change the activity will always remain current and will require little maintenance.

  • One possible option might be to force the learner to key in the date before advancing. But if you want to check the correctness of the date, or do any calculations with it, see Ron’s post. I don’t see a way it can be useful without checking it, and doing some calculation it.

  • Really simple with javascript all of your dates could be defined based on todays date

  • JesiWatts's avatar
    JesiWatts
    Community Member

    How would you go about doing this for a field entry in ASL? I found some javascripts on this: //

    Get the current date var currentDate = new Date();

    // Calculate the date 35 days in the future
    var futureDate = new Date(currentDate); futureDate.setDate(currentDate.getDate() + 35);

    // Format the future date as a string (optional)
    var formattedFutureDate = futureDate.toDateString();

    // Display the result
    console.log("Current Date:", currentDate.toDateString()); console.log("Future Date (35 days later):", formattedFutureDate);