Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All,
I need to calculate the week end date from my actual date field . I am bale to do it using below script :-
Weekend(FILE_DATE,0) as WeekEndDate
Right now , the end dates are coming as per Sunday of every week.
My requirement is to get week end date as Saturday of every week like below :-
01/01/2022
08/01/2022
15/01/2022
How can I achieve it ?
Thanks
why you don't just substract one day?
Date(Weekend(FILE_DATE,0)-1) as WeekEndDate
This will exactly give you the saturday
Please try this once-
IF(WeekDay(TempDate)='Sat',TempDate) as Weekend
Thanks,
Saloni
Hi @salonicdk28
I don't have Sat or Sun in my data set.
All I have is dates. On the basis of which i have calculated Weekend date like below :-
02/01/2022 - if you check this in calendar , it is Sunday .
I want my end date to be in the below sequence:-
01/01/2022- Saturday
08/01/2022- Saturday
15/01/2022- Saturday
So my weekend date column should have dates for Saturday for every week.
why you don't just substract one day?
Date(Weekend(FILE_DATE,0)-1) as WeekEndDate
This will exactly give you the saturday
even I don't have saturday or Sunday , I have date field only but it will work as weekday returns day name as sat or sun, give it a try
Hi
I think, you want ur week start from Sun to end with Sat. IF so, try like below
SET DayNames='Sun;Mon;Tue;Wed;Thu;Fri;Sat';
SET LongDayNames='Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday';
Weekend(FILE_DATE,0) as WeekEndDate
<-- this will give saturday as weekend
please keep in mind that WeekEnd() also returns an underlying time of 23:59:59.999, you could see e.g. with
Time(Date(WeekEnd(FILE_DATE)-1),'hh:mm:ss.fff')
or
Frac(Date(WeekEnd(FILE_DATE)-1))
To get proper (integer) Date values, you could as well use
DayName(WeekEnd(FILE_DATE)-1)
Set FirstWeekDay=6; //(set Sunday as the first day of the week)
so Saturday will be the last