Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
annalisa_carado
Partner - Contributor II
Partner - Contributor II

Change date to last friday?

Hi,

I'm developing an app and I need to do this customization:

for every record:

1) if date (in format YYYYMMDD) is a friday, no need change.

2) if is not a friday, need to change to last friday. (for example, today 20170313 has to change in 20170310).

I'm using num and weekday to extract the friday's , but I dont know how to continue.

Any help?

2 Replies
annalisa_carado
Partner - Contributor II
Partner - Contributor II
Author

i have done this: 

if(num(WeekDay( [Data di riferimento]) =0) ,[Data di riferimento] -3,
if(num(WeekDay( [Data di riferimento]) =1),[Data di riferimento] -4,
if(num(WeekDay( [Data di riferimento]) =2) ,[Data di riferimento] -5,
if(num(WeekDay( [Data di riferimento]) =3),[Data di riferimento] -6,
if(num(WeekDay( [Data di riferimento]) =4) ,[Data di riferimento],
if(num(WeekDay( [Data di riferimento]) =5),[Data di riferimento] -1,
if(num(WeekDay( [Data di riferimento]) =6),[Data di riferimento]-2,

is there another procedure more dynamic?

josephinetedesc
Creator III
Creator III

not an answer to your question - but this helped me !  I was trying to ensure that on a Friday we displayed the values for the following Monday - the SQL call was only a maximum of 4 days!

Thank you

Jo

if(num(WeekDay(Today())) = 1,  num(WeekDay(Today())) +2,   

    if(num(WeekDay(Today())) = 2,  num(WeekDay(Today())) +3    ,   

    if(num(WeekDay(Today())) = 3,  num(WeekDay(Today())) +4 ,   

    if(num(WeekDay(Today())) = 4,  num(WeekDay(Today())) +5    ,   

    if(num(WeekDay(Today())) = 5,  num(WeekDay(Today())) +3   

    )))))as DaysOfInt,