Skip to main content
Solved

Last Friday or weekday


Forum|alt.badge.img+1

How to calculate last Friday or current day of the week? Is there any weekday function available?

Best answer by AKislyakov

Hi ​@akshayl09,

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')

 

View original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+2
  • Ataccamer
  • 151 replies
  • Answer
  • April 22, 2025

Hi ​@akshayl09,

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')

 


Forum|alt.badge.img+1
  • Author
  • Data Pioneer
  • 20 replies
  • April 22, 2025

Thanks ​@AKislyakov , It works.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings