Conditions in segments: date & datetime
1. Date vs datetime
Formats of the attribute are usually set by analyst that implement Meiro Business Explorer. For date attribute (like birthday, date of particular action etc) it can be date or datetime type:
- Date (dd.mm.yyyy) for example: attribute Date of birth with values 12.9.1987
- Datetime (dd.mm.yyyy hh:mm:ss) for example: attribute date & time of the last clicked email 13.9.2020, 12:45:46. Datetime is useful for example for use cases with intervals of time smaller than 24 hours. For example to compare the result of the last 24 hours versus last 12 hours for a particular attribute.
First of all It is important to know check which one of those your date attribute is.
Imagine you wish to segment users that “exactly 24.02.2021 clicked on your email campaign”
In this case for:
- for date attributes, you will get the segment of customers that clicked on the email campaign 24.02.2021
- for datetime attributes you will get the segment of customers that clicked on the email campaign 24.02.2021 at a particular time (likely the one you saved your segment). This means that using "exactly" for datetime attributes will be more granular and may be misleading.
2. How to check if an attribute is a date or a datetime type
Examples of the attributes can be checked in the Attributes tab/ Data tab in the Examples section.
3. Conditions possible to check for date & datetimes attributes
Currently for date/ datetime attributes we support conditions:
- Exactly
- Since
- Until
- Since-Until
- Matches current day/ month/ year (week is coming soon)
- Matches last day/ week/ month/ year (is coming soon)
- As well as if the date is known or is not known.
Is is possible to use either calendar or natural language for :
- Exactly
- Since
- Until
- Since-Until
4. How natural language works
Natural language supports various commands, based on the Python parsedatetime library, like “now”, “today”, “yesterday”, “tomorrow”.
It is important to note that:
- for date attributes it will return and refer to dates.
- for datetimes attributes it will return and refer to date and exact time (when segment was saved).
For example:
If today is 24.02.2021 10:00, and in natural language section we specify “since yesterday” (yesterday in natural language), it will bring the result for:
- date attribute: all results since 23.02.2021 until now,
- datetime attributes: all results since 23.02.2021 10:00 until now.
“Today” vs “now”
For Datetime “today” will return the same date at 9:00, while now will return exact time (when the segment was saved).
“Midnight” or exact time
Exact time in natural language is especially useful for Datetime attributes. In this way we are sure what time and date we refer exactly to.
For example “since midnight 24.02.2021” will give results from 24.02.2021 00:00
or “since 23.02.2021 12:00” that will give results from 23.02.2021 12:00.
“-{number} days”
It is possible to insert “-{number} days”.
If today is 24.02.2021 13:53:51 for “-5 days” the result will be 2021-02-19 (but if attribute is datetime will also include reference to the current time: 2021-02-19 13:53:51).
“{number} days”
If today is 24.02.2021”20 days” will return 16.03.2021.
“monday”, “tuesday”, “wednesday”, “thursday”, “friday”, “saturday”, “sunday”
For “monday” the result will be the closest Monday. So if today is Wednesday 24.02.2021, the result will be 01.03.2021.
If today is Wednesday and in natural language we insert “wednesday”, the result will be the closest wednesday in the future in this case 03.03.2021.
"last monday 1 week ago"
The result will be the closest Monday 1 week ago. So for 24.02.2021 (Wednesday) result will bring 15.02.2021.
'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', “sep”, “oct”, “nov”, “dec”
Those will return 1st of the month of the current year. So if today is 24.02.2021, “jan” will return “01.01.2021”.
Warnings: “last week”: If today is 24.02.2021 will return 17.01.2020 9:00, "last month”: If today is 24.02.2021 will return 01.01.2021 9:00; “last year”: If today is 24.02.2021 will return 01.01.2020 9:00.
5. Best practices
Current day/ month/ year
For matching current day/ month/ year (week, matching last day/ week/ month/ year is coming soon) it is recommended to use respective conditions:
Matches current day- will give results that happened on the same date when the segment was saved. For example if the segment was saved 04.02.2021, the result will be shown for 04.02.2021.
Matches current month- will give results that happened the same month when segment was saved. For example if the segment was saved 04.02.2021, the result will be shown from 01.02.2021.
Matches current year- will give results that happened the same year when the segment was saved. For example if the segment was saved 04.02.2021, the result will be shown from 01.01.2021.
Yesterday
For date attribute: exactly “yesterday”, or since "yesterday" until "now" for results that are happening from yesterday until now.
For datetime attribute it must be specified further: Since “yesterday midnight” until “today midnight”, or since “yesterday midnight” until now for results that are happening from yesterday until now.
ConditionaCondition: ”matches yesterday” is coming soon.
Results for the last 7 days/ 14 days
To get the results for the last 7 days, for date attributes it is possible to use since "-7days" (or "7 days ago"), until "now".
To get the results for the last 7 days, for datetime attributes it is possible to use since "-7days midnight" (or "7 days ago"), until "now".
To get the results for the last 14 days, for date attributes it is possible to use since "-14days midnight" (or "14 days ago"), until "now".
Exactly
It is recommended for dates.
It is NOT recommended for datetimes, as it may be too precise.
For example: "Exactly yesterday" if today is 24.02.2021
- The attribute date will select 23.02
- Attribute datetim will select 23.02 11:54:00
Warning: Exactly “- days” (for the datetime it may return results matching exact day & time). “Exactly today” will return today at 9:00. More precise result would bring: since “midnight -3days” and until “midnight -2days”.
Datetime and "-{number} hours"
For datetime useful commands may be “now -{number} hours”, like “now -12hours” (to get the result from not until 12 hours ago).