Relative date searches work well in combination with saved filters and allow you to enter a date criteria "relative" to the current date.
For example, if today is Thursday the 8th of October 2015, and I want to find all contacts created in the last 3 days, I could enter one of two things:
- Contacts created after 05/10/2015
- Contacts created after ~3 days ago
The advantage of entering the search in the second way is two fold:
- ~3 days ago is quite clear and we don't have to do any date math
- I can re-run this search at a later date and know that it will work successfully
Any date or time criteria in Rex can accept a relative time period. To enter a period, simply click into the date or time field and enter the character "~" followed by your relative time expression.
What follows is the basic rules, sets of examples and quirks when using this functionality. All of the examples assume the current date and time is Thursday the 8th of October 2015 at 3:33pm.
Rules
Operator | Examples | Meaning |
"-" prefix trailing "ago" |
-3 days 3 days ago |
Subtract the time period from the current date |
"+" prefix trailing "from now" "in" prefix no prefix |
3 days in 3 days 3 days from now +3 days |
Add the time period to the current date |
this the |
first day of this week first day of the week |
Indicates the current period as opposed to previous / next |
previous last |
last week previous thursday |
The previous occurrence of a day |
last |
last thursday of july 2008 last day of three months from now |
When used in combination with a month or day this indicates that the system should look for the last occurrence of a day or day name |
next |
next thursday next month |
The next occurrence of a particular day |
"last second of" prefix "last second" suffix |
last second of december 31st 2008 | The final second of the given day 11:59:59 |
"," | 3 days ago, 7 hours ago | Apply multiple expressions to modify the current date. First 3 days are subtracted from Thursday the 8th of October 3:33pmgiving us Thursday the 5th of October 3:33pm then 7 hours are subtracted giving us Thursday 5th of October 8:33am. |
Examples
Simple Expressions
Expression | Effective Date | Explanation |
Now | Thu 8th October 2015 03:33pm | The current time |
Noon | Thu 8th October 2015 12:00pm | Midday of today |
Midnight | Thu 8th October 2015 12:00am | Midnight of today |
Today | Thu 8th October 2015 12:00am | Midnight of today |
Yesterday | Wed 7th October 2015 12:00am | Midnight of yesterday |
2 Hours from now | Thu 8th October 2015 05:33pm | Current time + 2 hours |
2 Hours ago | Thu 8th October 2015 01:33pm | Current time - 2 hours |
-2 Hours | Thu 8th October 2015 01:33pm | Current time - 2 hours |
2 days ago | Sat 10th October 2015 03:33pm | Current time - 2 days (48 hours) |
3 days ago | Mon 5th October 2015 03:33pm | Current time - 3 days (72 hours) |
10 weekdays | Thu 24th September 2015 12:00am | Current time - 10 weekdays (note it ignores weekends) |
Days of Week
Expression | Effective Date | Explanation |
This Wednesday | Wed 14th October 2015 12:00am | The next coming Wednesday (or today if today is Wednesday) |
This Thursday | Thu 8th October 2015 12:00am | The next coming Thursday (or today if today is Thursday) |
Next thursday | Thu 15th October 2015 12:00am | Always the Thursday after the current Thursday. If today is Thursday, Thursday next week. |
Last Monday | Mon 5th October 2015 12:00am | The most recent Monday (Monday this week). If today is Monday then Monday last week. |
Monday | Mon 12th October 2015 12:00am | Same as next Monday. |
Monday next Week | Mon 12th October 2015 12:00am | Monday of the next week. |
Monday this Week | Mon 5th October 2015 12:00am | Monday of the current week (even if it has passed). |
Monday last Week | Mon 28th September 2015 12:00am | Monday of the week before the current week. |
Days of Month
Expression | Effective Date | Explanation |
Last Tuesday of December | Tue 29th December 2015 12:00am | December this year then the last Tuesday of that month. |
First day of this month | Thu 1st October 2015 03:33pm | First day of the current month |
First day of 2 months ago | Sat 1st August 2015 03:33pm | 2 Months ago (August) and then the first day of that month |
First day of January | Thu 1st January 2015 03:33pm | First day of January in the current year |
First day of January Next Year | Fri 1st January 2016 03:33pm | First day of January in the next year |
First day of October | Thu 1st October 2015 03:33pm | First day of October in the current Year |
First day of 3 months ago | Wed 1st July 2015 03:33pm | First day of the month 3 months ago |
First day of next month | Sun 1st November 2015 03:33pm | The first day of the following month (same time) |
Next month | Sun 8th November 2015 03:33pm | The same date and time in the following month |
First Monday of next Month | Mon 2nd November 2015 12:00am | The first Monday of next month |
First day of 2 months ago | Sat 1st August 2015 03:33pm | Two months ago (August), the first day of the month |
Months
Expression | Effective Date | Explanation |
June this year | Mon 8th June 2015 03:33pm | Current day of June this year |
June last year | Sun 8th June 2014 03:33pm | Current day of June next year |
June 2014 | Sun 1st June 2014 03:33pm | This is a special expression and is treated not as a modifier but as a specific date: First day of June 2014 (same time of day) |
Last day of this month | Sat 31st October 2015 03:33pm | Last day of the current month |
Last day of 6 months ago | Thu 30th April 2015 03:33pm | Last day of 6 months ago (April). |
Last day of june 2014 | Mon 30th June 2014 03:33pm | Last day of June 2014. |
Years
Expression | Effective Date | Explanation |
Last year: | Wed 8th October 2014 03:33pm | Same day of the same month at the same time in the previous year |
Next year | Sat 8th October 2016 03:33pm | Same day of the same month at the same time in the following year |
1 month ago | Tue 8th September 2015 03:33pm | Same time on the same day of the previous month. If the current day does not exist in the previous month (e.g. 30th of June 2015,-1 month) then it will land on an appropriate day in the subsequent month (1 June 2015). |
Combined / Compound Expressions
Combined expressions are basically multiple relative date / time expressions separated by commas. The first expression is applied against the current date and time which produces a new date and time. The next expression is applied against that new date time and so on and so forth.
Expression | Effective Date | Explanation |
2 months, 3 days ago | Wed 5th August 2015 03:33pm | Same day of the month 2 months ago... THEN subtract 3 days. |
-2 months, +3 days | Fri 11th December 2015 03:33pm | Same day of the month 2 months ago... THEN add 3 days |
First day of next month, Last second | Sat 31st October 2015 11:59pm | First day of next month (1st of October 3:33pm)... THEN last second (1st of October 11:59:59PM) |
last month, last day of this month | Wed 30th September 2015 03:33pm | Previous month (September)... THEN last day of this month (September) |
Next Year, 30 September | Fri 30th September 2016 03:33pm | Same day of the same month at the same time of the next year... THEN 30 September of the current year (2016) |
June 2014, first day of this month, -1 year | Sat 1st June 2013 00:00am | Same day (8th) of June 2014... THEN first day of this month (1st of June 2014)... THEN subtract one year (1st of June 2014) |
Quirks
There are a few quirky behaviors particularly in relation to month math.
When on a day of the month that does not exist in the following month (or previous month). Assume that the current date is 31 July 2015:
Desired Outcome |
Effective Date |
Why does this happen | Resolution |
Last day of the previous month | July 1st | June only has 30 days. In order for a valid date to exist we move to the first day of the next month. | first day of this month, last month, last day of the month |
3 months ago | May 1st | July minus three months is April. The 31st day of April does not exist (there are only 30 days in april). In order for a valid date to exist we move to the first day of the next month. |
Remove the invalid day of month by requesting the first or last day of month
|