This function finds if timestamp lies inside the part of the lunar week up to and including the last millisecond of base_date. Lunar weeks in Qlik Sense are defined by counting 1 January as the first day of the week.
InLunarWeekToDate (timestamp, base_date, period_no [, first_week_day])
|timestamp||The date that you want to compare with base_date.|
|base_date||Date that is used to evaluate the lunar week.|
|period_no||The lunar week can be offset by period_no. period_no is an integer, where the value 0 indicates the lunar week which contains base_date. Negative values in period_no indicate preceding lunar weeks and positive values indicate succeeding lunar weeks.|
|first_week_day||An offset that may be greater than or less than zero. This changes the beginning of the year by the specified number of days and/or fractions of a day.|
|inlunarweektodate('12/01/2013', '13/01/2013', 0)||Returns True. Because the value of timestamp, 12/01/2013 falls in the part of the week 08/01/2013 to 13/01/2013.|
|inlunarweektodate('12/01/2013', '11/01/2013', 0)||Returns False. Because the value of timestamp is later than the value base_date even though the two dates are in the same lunar week before 12/01/2012.|
|inlunarweektodate('12/01/2006', '05/01/2006', 1)||Returns True. Specifying a value of 1 for period_no shifts the base_date forward one week, so the value of timestamp falls in the part of the lunar week.|
Add the example script to your app and run it. To see the result, add the fields listed in the results column to a sheet in your app.
This example checks if an invoice date falls in the part of the week shifted from the value of base_date by four weeks.
LOAD RecNo() as InvID, * Inline [
InLunarWeekToDate(InvDate, '07/01/2013', 4) AS InLWeek2DPlus4
Drop table TempTable;
The resulting table contains the original dates and a column with the return value of the inlunarweek() function.
The function returns True for the value of InvDate5/2/2013 because the value of base_date, 11/01/2013, is shifted by four weeks, and so falls in the part of the week 5/02/2013 to 07/02/2013.