Hi,
Is there a funcion (or algorithm) that returns the day of the week for a particular date (yyyymmdd)?
Best
Ari
day of the week
Re: day of the week
In CSPro 7.1 we added the timstring function that can do this: http://www.csprousers.org/help/CSPro/ti ... ction.html
In earlier versions of CSPro you could write a function like this to do it:
In earlier versions of CSPro you could write a function like this to do it:
// Compute day of week from date
// Returns 1 for Sunday, 2 for Monday..
function dayOfWeek(yyyymmdd)
numeric referenceDay = 20170827; // This was be a Sunday
numeric diff = datediff(referenceDay, yyyymmdd, "d");
dayOfWeek = diff % 7 + 1;
end;
The above function is from the Labor Force Survey example in the CSPro examples folder.// Returns 1 for Sunday, 2 for Monday..
function dayOfWeek(yyyymmdd)
numeric referenceDay = 20170827; // This was be a Sunday
numeric diff = datediff(referenceDay, yyyymmdd, "d");
dayOfWeek = diff % 7 + 1;
end;