Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Generate a Calendar

I need to create a calendar like the one below. The column "Date" is the date an employee punched a time clock. The "WeekEnding" date the week the time clock punch relates to - our week ends on Sunday. The "PayPeriodEnding" is date the person is paid for the time clock punch. We pay bi weekly on Fridays one week "late".

The first date in the calendar would be12/26/2012 and the last date would be the oldest date in a file of time (date) punches.

Thanks,
Stephen

DayDateWeekEndingPayPeriodEnding
Mon12/26/20111/1/20121/13/2012
Tue12/27/20111/1/20121/13/2012
Wed12/28/20111/1/20121/13/2012
Thu12/29/20111/1/20121/13/2012
Fri12/30/20111/1/20121/13/2012
Sat12/31/20111/1/20121/13/2012
Sun1/1/20121/1/20121/13/2012
Mon1/2/20121/8/20121/13/2012
Tue1/3/20121/8/20121/13/2012
Wed1/4/20121/8/20121/13/2012
Thu1/5/20121/8/20121/13/2012
Fri1/6/20121/8/20121/13/2012
Sat1/7/20121/8/20121/13/2012
Sun1/8/20121/8/20121/13/2012
Mon1/9/20121/15/20121/27/2012
Tue1/10/20121/15/20121/27/2012
Wed1/11/20121/15/20121/27/2012
Thu1/12/20121/15/20121/27/2012
tlkpCalendar
4 Replies
swuehl
MVP
MVP

"The first date in the calendar would be12/26/2012 and the last date would be the oldest date in a file of time (date) punches."

Hm, I haven't really understood that requirement, I think your last date should be the youngest date in the file?

Otherwise you won't have much matches between your punch table and the calendar, right?

So I just tried to replicate the above table. I believe you should be able to easily adjust the number of dates (replace the fix number of records after the autogenerate with a difference of EndDate - StartDate+1. One of the dates could be retrieved from another table using a separate load with max(PunchDate) or min(PunchDate) or a punch table load ordered by PunchDate and Peek() function).

Here is what should give you above calendar:

Calendar:

LOAD *,

WeekEnd(Date) as WeekEnding,

WeekDay(Date) as Day,

date(floor(weekstart(Date)+18,14,MakeDate(2012,1,13))) as PayPeriodEnding;

LOAD

Date(makedate(2011,12,26)+recno()-1) as Date

autogenerate 100;

Hope this helps,

Stefan

Not applicable
Author

Hello Stefan,

WeekEnding is working but the PayPeriodEnding is now.

Stephen

swuehl
MVP
MVP

If I just copy the above snippet into a new document, I get values for PayPeriodEnding that matches your above table.

What do you mean with 'not working', do you get no values at all returned or values different from the above reference? If latter, what do you see?

Or maybe you have already modifed the script to adapt the range to your needs. If so, could you please post your script snippet or qvw?

Not applicable
Author

Stefan,

First, yes your code works perfectly. I must have pasted in something wrong.

Second, I modified the PayPeriodEnding to be:

date(floor(weekstart(Date)+25,14)-1) as PayPeriodEnding

this gives me the same results as your code without having to hard code the "MakeDate(2012,1,13)"

Stephen