Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i need to find min and max dates for current week
LET vCW = peek('CYW',0,'table1');
LET vMinCurrentWk = (WeekStart($(vCW))));
LET vMaxCurrentWk = WeekDay(WeekEnd($(vCW)));
please help
vCW is returning current yearweek. No issue with this. But need to find min and max of current week.
How does your vCW (current yearweek) value look like? Is it a string or number?
What's the format of your yearweek value? 'YYYYWW'?
You can use
MakeWeekDate(YYYY [ , WW [ , D ] ] )
function to create a date from your yearweek value:
LET vMinCurrentWk = MakeWeekDate(Left('$(vCW)',4),Right('$(vCW)',2));
LET vMaxCurrentWk = WeekDay(WeekEnd(MakeWeekDate(Left('$(vCW)',4),Right('$(vCW)',2))));
vCW looks like '201628' , i.e like 'YYYYWK' yearweek
I want to get min and max dates for current week.
table1:
NoConcatenate
LOAD
yrwk as CYW
Resident CAL
Order By@@
calYRWK
;
LET vCW= peek('CYW',0,'table1');
LET vMindateCWk = ?
LET vMaxdateCtWk = ?
please help
Have you tried something like I've suggested above, using MakeWeekDate() function?
LET vMindateCWk = MakeWeekDate(Left('$(vCW)',4),Right('$(vCW)',2));
LET vMaxdateCtWk = DayName(WeekEnd(MakeWeekDate(Left('$(vCW)',4),Right('$(vCW)',2))));
Maybe
WeekStart(MakeWeekDate(left('201628', 4), Right('201628', 2)))
WeekEnd(MakeWeekDate(left('201628', 4), Right('201628', 2)))
Replace 201628 with your field or variable
WeekStart/End return a timestamp
this will work only for 201628 , I guess what @swuehl solution will work, but I wan the Min date to start from Sunday, and Max date to be Saturday. Like current week would be Sun to Sat
Min date is 7/11/2016 which is monday...and max date is 7/17/2016
I need min date to start from Sunday
Also, within the script, how to calculatea metric for (current week + next 3 weeks) data -> next 3 weeks should be updated everyday. Please help
MakeWeekDate() function uses ISO weeks.
If your week numbering matches ISO weeks, with just start of week being Sunday, you can just subtract 1 from the date that MakeWeekDate() returns (QlikView uses internally integer numbers to represent dates).
See also
If you need current weeks date why peek in to a table row?
LEt vMinWeekDate = WeekStart(now(),0,6); //Mondays Date
LEt vMaxWeekDate = WeekEnd(now(),0,6); // Sundays Date