Days since last Wednesday

Reply
White Belt

Days since last Wednesday

Hello.  I'd like to make a calculated fiield to show datediff('end date','last thursday').  how do I represent 'last thursday' in that?  The 'end date' is a sate in my data.


Accepted Solutions
White Belt

Re: Days since last Wednesday

Ended up using this to be the 'last Thursday' part.  Not sure if ther is a more elegant way for it but it does the job.

case
when DAYOFWEEK(CURRENT_DATE())=1 then CURRENT_DATE()-3
when DAYOFWEEK(CURRENT_DATE())=2 then CURRENT_DATE()-4
when DAYOFWEEK(CURRENT_DATE())=3 then CURRENT_DATE()-5
when DAYOFWEEK(CURRENT_DATE())=4 then CURRENT_DATE()-6
when DAYOFWEEK(CURRENT_DATE())=5 then CURRENT_DATE()-1
when DAYOFWEEK(CURRENT_DATE())=6 then CURRENT_DATE()-2
when DAYOFWEEK(CURRENT_DATE())=7 then CURRENT_DATE()-3
end


All Replies
White Belt

Re: Days since last Wednesday

Ended up using this to be the 'last Thursday' part.  Not sure if ther is a more elegant way for it but it does the job.

case
when DAYOFWEEK(CURRENT_DATE())=1 then CURRENT_DATE()-3
when DAYOFWEEK(CURRENT_DATE())=2 then CURRENT_DATE()-4
when DAYOFWEEK(CURRENT_DATE())=3 then CURRENT_DATE()-5
when DAYOFWEEK(CURRENT_DATE())=4 then CURRENT_DATE()-6
when DAYOFWEEK(CURRENT_DATE())=5 then CURRENT_DATE()-1
when DAYOFWEEK(CURRENT_DATE())=6 then CURRENT_DATE()-2
when DAYOFWEEK(CURRENT_DATE())=7 then CURRENT_DATE()-3
end

Announcements
Looking for the latest Community solutions? Please visit our accepted solutions board here!