If needed, use 'Help > Scripting Index' to find more details of how the commands work;
NamesDefaultToHere(1);
// Make a table of random dates
n = 50;
startDate = Date DMY( 01, 1, 2016 );
endDate = Date DMY( 12, 10, 2016 );
dates = Sort Ascending( J( n, 1, Random Integer(startDate, endDate) ) );
dt = New Table( "Dates",
New Column( "Random dates", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Set Values( dates )),
);
// Add a formula for the day of the week
nc = dt << New Column( "Day of the week",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Day Of Week( :Random dates ) ),
Value Labels(
{1 = "Sunday", 2 = "Monday", 3 = "Tuesday", 4 = "Wednesday", 5 = "Thursday",
6 = "Friday", 7 = "Saturday"}
),
Use Value Labels( 1 ),
);
// Make a subset table
r = dt << getRowsWhere(:Day of the week == 7 | :Day of the week == 1);
dt2 = dt << Subset(rows(r), LinkToOriginalDataTable(1));
dt2 << setName("Weekend Dates");