Skip to main content
Solved

Last Friday or weekday

  • Apr 16, 2025 4:55 PM UTC
  • 2 replies
  • 172 views

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

2 replies

Forum|alt.badge.img+2
  • Ataccamer
  • Answer
  • Apr 22, 2025 1:26 AM UTC

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
  • Apr 22, 2025 11:41 AM UTC

Thanks ​@AKislyakov , It works.