The Date/getDaysOfWeek extension generates an array of formatted dates starting from the current date.
This is useful when a journey needs a list of upcoming dates, such as the next seven days, in a specific display format for date validation or test data generation.
Parameters:
-
daysrequiredrequired, a string or number representing how many dates should be generated. The script converts this value usingparseInt(daysrequired); -
dateFormatrequired, a string containing the Moment.js date format used to format each returned date;
Note: The first returned value is based on the current date. Each next value adds one calendar day using Moment.js add(i, 'd').
NLP usage
Use the extension in a journey by calling Date/getDaysOfWeek with the execute command. Pass each value to the matching extension input using as inputName.
Note: The dateFormat value must be compatible with Moment.js formatting tokens.
execute "Date/getDaysOfWeek" using "7" as daysrequired using "ddd DD MMM" as dateFormat returning $daysInAWeekexecute "Date/getDaysOfWeek" using "5" as daysrequired using "YYYY-MM-DD" as dateFormat returning $weekDatesYou can also pass stored variables into the extension inputs.
execute "Date/getDaysOfWeek" using "$numberOfDays" as daysrequired using "$format" as dateFormat returning $daysInAWeekstore value "7" in $numberOfDays
store value "ddd DD MMM" in $format
execute "Date/getDaysOfWeek" using "$numberOfDays" as daysrequired using "$format" as dateFormat returning $daysInAWeekExample output for seven dates formatted as ddd DD MMM:
[
"Mon 25 May",
"Tue 26 May",
"Wed 27 May",
"Thu 28 May",
"Fri 29 May",
"Sat 30 May",
"Sun 31 May"
]This extension requires the following resources:
The extension should be configured as:
- Run asynchronously: No
- Scope: Global
Limitation: The script depends on Moment.js being loaded from the configured resource. It uses the current browser/runtime date and timezone, so results may vary depending on where the journey is executed. The daysrequired input is parsed with parseInt, so non-numeric or partially numeric values may produce unexpected output, and the script does not add validation for invalid date formats.
Add the extension to your Virtuoso instance
Select the domain that matches your Virtuoso account.
View source
Last updated: 25/05/2026
Resources:
// Note this extension is not a product feature of Virtuoso and is not officially supported
// Extensions use javascript which may or may not be compatible with systems under test (SUTs)
// We welcome you to use this extension or adapt it for your needs
const getWeekDates = () => {
let weekDates = [];
for (let i = 0; i < parseInt(daysrequired); i++)
weekDates.push(moment().add(i, 'd').format(dateFormat));
return weekDates;
};
return (getWeekDates())
/*const possibleFormats = [
"YYYY-MM-DD",
"DD/MM/YYYY",
"MM/DD/YYYY",
"DD.MM.YYYY",
"YYYY/MM/DD",
"DD-MM-YYYY",
"MM-DD-YYYY",
"DD MMM YYYY",
"MMM DD, YYYY",
"MMMM DD, YYYY",
"YYYY MMM DD",
"YYYY-DD-MM",
// Add more formats as needed
];*/
Comments
0 comments
Please sign in to leave a comment.