Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Aspiring_Developer
Creator III
Creator III

Get weekend date from date

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

Aspiring_Developer_0-1644305091561.png

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

 

1 Solution

Accepted Solutions
chris_djih
Creator III
Creator III

why you don't just substract one day?
Date(Weekend(FILE_DATE,0)-1) as WeekEndDate

This will exactly give you the saturday

If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.

View solution in original post

7 Replies
salonicdk28
Creator II
Creator II

Please try this once-

IF(WeekDay(TempDate)='Sat',TempDate) as Weekend

Thanks,

Saloni

Aspiring_Developer
Creator III
Creator III
Author

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.

 

chris_djih
Creator III
Creator III

why you don't just substract one day?
Date(Weekend(FILE_DATE,0)-1) as WeekEndDate

This will exactly give you the saturday

If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.
salonicdk28
Creator II
Creator II

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 

MayilVahanan

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

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
MarcoWedel

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)

 

 

 

 

Sir_Johanos
Contributor II
Contributor II

Set FirstWeekDay=6; //(set Sunday as the first day of the week)

so Saturday will be the last