How to calculate last Friday or current day of the week? Is there any weekday function available?
Solved
Last Friday or weekday
Best answer by AKislyakov
Hi
You can use toString function to get the name/number of the current day of the week using SimpleDateFormat (Java Platform SE 8 ) notion. Naming and numbering are dependent on the locale used (e.g. 1 is Sunday in US, Monday in GB). And then create a conditional logic to calculate the last Friday.
Alternatively, if your dates reliably lie within certain range, you can use some known Friday and calculate weeks from it. E.g. if valid dates are in this century, you can use following expression.
dateAdd(toDate('31-12-1999','dd-MM-yyyy'), (dateDiff(toDate('31-12-1999','dd-MM-yyyy'), in_dt, 'DAY') div 7) * 7, 'DAY')
Reply
Login to the Ataccama Community
No account yet? Create an account
For Ataccama Customers and Partners
or
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.