
There a clever query utility which let’s you create dynamic ranges.
The different options are (today’s date is 25-02-2014):
- (dayRange(-30,0)) – Results in a date range for the last 30 days: “26-01-2014”..”25-02-2014″
- (day(-1)) – Results in yesterday’s date: 24-02-2014
- (day(0)) – Results in today’s date: 25-02-2014
- (day(1)) – Results in tomorrow’s date: 26-02-2014
- (greaterThanDate(2)) – Results in every date after today plus 2: > 27-02-2014
- (lessThanDate(-1)) – Results in every date of today minus 1: < 24-02-2014
- (monthRange(0,2)) – Results in first day till the last day of the month’s choosen (0 = current month): “01-02-2014”..”30-04-2014″
- (yearRange(-1,-1)) – Results in first day till the last day of the chosen year: “01-01-2013”..”31-12-2013″
To see the results in a job or to play around with the different date options, you can copy and use the job below:
static void JLH_sysQueryRangeUtil(Args _args)
{
str dateRange;
// In the following date examples, date of today (25-02-2014) is taken
dateRange = sysQueryRangeUtil::dayRange(-30,0); // Results in a date range for the last 30 days: "26-01-2014".."25-02-2014"
info(strfmt(dateRange));
dateRange = sysQueryRangeUtil::day(-1); // Results in yesterday's date: 24-02-2014
info(strfmt(dateRange));
dateRange = sysQueryRangeUtil::day(1); // Results in tomorrow's date: 26-02-2014
info(strfmt(dateRange));
dateRange = sysQueryRangeUtil::greaterThanDate(2); // Results in every date after today plus 2: > 27-02-2014
info(strfmt(dateRange));
dateRange = sysQueryRangeUtil::lessThanDate(-1); // Results in every date of today minus 1: < 24-02-2014
info(strfmt(dateRange));
dateRange = sysQueryRangeUtil::monthRange(0,2); // Results in first day till the last day of the month's chosen (0 = current month): "01-02-2014".."30-04-2014"
info(strfmt(dateRange));
dateRange = sysQueryRangeUtil::yearRange(-1,-1); // Results in first day till the last day of the chosen year: "01-01-2013".."31-12-2013"
info(strfmt(dateRange));
}
Leave a comment