indaytotime - script and chart function
This function returns True if timestamp lies inside the part of day containing base_timestamp up until and including the exact millisecond of base_timestamp.
Syntax:
InDayToTime (timestamp, base_timestamp, period_no[, day_start])
Return data type: Boolean
Arguments:
Argument | Description |
---|---|
timestamp | The date and time that you want to compare with base_timestamp. |
base_timestamp | Date and time that is used to evaluate the timestamp. |
period_no | The day can be offset by period_no. period_no is an integer, where the value 0 indicates the day which contains base_timestamp. Negative values in period_no indicate preceding days and positive values indicate succeeding days. |
day_start | (optional) If you want to work with days not starting midnight, indicate an offset as a fraction of a day in day_start, For example, 0.125 to denote 3 AM. |
Example 1:
indaytotime ('12/01/2006 12:23:00', '12/01/2006 23:59:00', 0)
Returns True
Example 2:
indaytotime ('12/01/2006 12:23:00', '12/01/2006 00:00:00', 0)
Returns False
Example 3:
indaytotime ('11/01/2006 12:23:00', '12/01/2006 23:59:00', -1)
Returns True
Example 4:
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 timestamp falls before 17:00:00 on the day starting with the base_timestamp.
TempTable:
LOAD RecNo() as InvID, * Inline [
InvTime
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 *,
InDayToTime(InvTime, '28/03/2012 17:00:00', 0) AS InDayExTT
Resident TempTable;
Drop table TempTable;
The resulting table contains the original dates and a column with the return value of the indaytotime() function.
InvTime | InDayExTT |
---|---|
28/03/2012 | -1 (True) |
10/12/2012 | 0 (False) |
5/2/2013 | 0 (False) |
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) |