Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating a week field based on system date?

Hi all there,

How can I create a weekend dates field using system date and weekend date should be every Sunday??

Example:

Weekend

05/01/2016

05/08/2016

05/15/2016

05/22/2016

05/29/2016

likewise for every month??

13 Replies
sunny_talwar

What's the significane of system date here? WeekEnd would be a weekend right, or am I missing something important here?

MindaugasBacius
Partner - Specialist III
Partner - Specialist III

I strongly recommend you in the Master calendar just add one additional flag like:

If(weekday(date) = 6, 1, 0) as Weekend_flag;

Not applicable
Author

I have one date field in data, but i should not use that date field to get the weekend dates, so i thought that it can be done using system date, if any other possibility, let me know

Thanks

Prashanth

sunny_talwar

Once again. I am not sure what system date needs to do here? System date should be 06/03/2015 (today), what does that need to do with the weekend? Do you just want the weekend based on Today's date? try this

WeekEnd(Today(), 0, 0)

Not applicable
Author

I have only one date field which i should not use to create weekend dates field. so i thought like system will do the job. Is there any possibility to get the same without any date column?

thanks

Prashanth

Not applicable
Author

Okay let me clarify you one thing. I have date field like

Postdate

05/04/2016

05/09/2016

05/15/2016

05/17/2016

I need to create weekend dates for respective records

Expected:

Postdate          CreatedWeendend

05/04/2016       05/08/2016

05/09/2016        05/15/2016

05/12/2016        05/0152016

05/17/2016        05/22/2016


thanks

Prashanth

sunny_talwar

Try like this:

SET FirstWeekDay=0;

LOAD Postdate,

          WeekEnd(Postdate, 0, 0) as CreatedWeendend

FROM Source;


UPDATE:
Added an environmental variable

Not applicable
Author

sorry to confuse you, but I should not use the Post date field. Any other way that can do the job??

sunny_talwar

But if you are using Postdate as reference point, how can you not use it? Outside QlikView how would you do this?