inweektodate - script and chart function
This function returns True if timestamp lies inside the part of week containing base_date up until and including the last millisecond of base_date.
InWeekToDate (timestamp, base_date, period_no [, first_week_day])
Return data type: Boolean
|timestamp||The date that you want to compare with base_date.|
|base_date||Date that is used to evaluate the week.|
|period_no||The week can be offset by period_no. period_no is an integer, where the value 0 indicates the week which contains base_date. Negative values in period_no indicate preceding weeks and positive values indicate succeeding weeks.|
By default, the first day of the week is Monday,starting at midnight between Sunday and Monday. To indicate the week starting on another day, specify an offset in first_week_day. This may be given as a whole number of days and/or fractions of a day.
inweektodate ('12/01/2006', '12/01/2006', 0)
inweektodate ('12/01/2006', '11/01/2006', 0)
inweektodate ('12/01/2006', '18/01/2006', -1)
Because period_no is specified as -1, the effective data that timestamp is measured against is 11/01/2006.
inweektodate ( '11/01/2006', '12/01/2006', 0, 3 )
Because first_week_day is specified as 3 (Thursday), which makes 12/01/2006 the first day of the week following the week containing 12/01/2006.
Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in your document to see the result.
This example checks if an invoice date falls during the fourth week after the week in base_date, by specifying period_no as 4, but before the value of base_date.
LOAD RecNo() as InvID, * Inline [
InWeekToDate(InvDate, '11/01/2013', 4) AS InWeek2DPlus4
Drop table TempTable;
The resulting table contains the original dates and a column with the return value of the inweek() function.