Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Deriving Week from Sysdate


How can we derive last 5 weeks from sysdate . The week should be from Saturday to Friday . Today is monday means we should have last Saturday(22 nd Sep - 29 sEP), similarly i need to derive last 5 weeks.

Thanks,

Abhi

5 Replies
Not applicable
Author

Can somebody help me on this pls?

swuehl
MVP
MVP

Last saturday was Sep 28th, not 22nd or 29th. Or do you want a week from Sunday to Saturday instead?

Well, if you want a week Saturday to Friday, you can use weekstart and weekend functions with an weekstart offset:

This week:

weekstart(today(),0,-2)      to      daystart(weekend(today(),0,-2))

Previous weeks:

weekstart(today(),-1,-2)      to      daystart(weekend(today(),-1,-2))

weekstart(today(),-2,-2)      to      daystart(weekend(today(),-2,-2))

weekstart(today(),-3,-2)      to      daystart(weekend(today(),-3,-2))

weekstart(today(),-4,-2)      to      daystart(weekend(today(),-4,-2))

Not applicable
Author

This is static right. I want this to be dynamic, so that it always brings last week frpm Sunday - Saturday. If it runs today it should bring from 22nd - 28th until this week is finished. The output will be same until we have the complete week.

tresesco
MVP
MVP

It's not static. It can be implemented dynamically as well. Please share a sample app with explained expected output; you might be helped in an efficient way. You might want to have a look at this qlikview design post by Henric Cronström for better understanding and learning.

swuehl
MVP
MVP

No, it's not static, it uses today() with relative week offsets (0, -1, -2, -3, -4).Last week is indicated by -1 and so on:

weekstart(today(),-1,-2) 

to  daystart(weekend(today(),-1,-2))