# 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.

Syntax:

InWeekToDate (timestamp, base\_date, period\_no [, first\_week\_day])

**Return data type:** Boolean

Arguments:

InWeekToDate arguments

| Argument | Description |
| --- | --- |
| 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.<br>period\_no is an integer, where the<br>value 0 indicates the week which contains base\_date.<br>Negative values in period\_no indicate<br>preceding weeks and positive values indicate succeeding weeks. |
| first\_week\_day | By default, the first day of the week is Monday,starting at midnight between Sunday and Monday. To<br>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<br>a day. |

Example 1:

`inweektodate ('12/01/2006', '12/01/2006', 
 0)`

Returns True

Example 2:

`inweektodate ('12/01/2006', '11/01/2006', 
 0)`

Returns False

Example 3:

`inweektodate ('12/01/2006', '18/01/2006', 
 -1)`

Returns False  
Because period\_no is specified as -1, the effective data that timestamp is measured against is 11/01/2006.

Example 4:

`inweektodate ( '11/01/2006', '12/01/2006', 0,
3 )`

Returns False  
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.

Example 5:

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.

`TempTable:` `LOAD RecNo() as InvID, * Inline [` `InvDate` `28/03/2012` `10/12/2012` `5/2/2013` `31/3/2013` `19/5/2013` `15/9/2013` `11/12/2013` `2/3/2014` `14/5/2014` `13/6/2014` `7/7/2014` `4/8/2014` `];` ` ` `InvoiceData:` `LOAD *,` `InWeekToDate(InvDate, '11/01/2013', 4) AS InWeek2DPlus4` `Resident TempTable;`

`Drop table TempTable;`

The resulting table contains the original dates and a column with the return value of the inweek() function.

Example 5 results

| InvDate | InWeek2DPlus4 |
| --- | --- |
| 28/03/2012 | 0 (False) |
| 10/12/2012 | 0 (False) |
| 5/2/2013 | -1 (True) |
| 31/3/2013 | 0 (False) |
| 19/5/2013 | 0 (False) |
| 15/9/2013 | 0 (False) |
| 11/12/2013 | 0 (False) |
| 2/3/2014 | 0 (False) |
| 14/5/2014 | 0 (False) |
| 13/6/2014 | 0 (False) |
| 7/7/2014 | 0 (False) |
| 4/8/2014 | 0 (False) |