Sometime you want to segment user with dates or timeframes, e.g. an anniversay like a birthday that will come up in a week, or certain events that happened withing the last 3 weeks, a contract expires in a month or similar.
The timestamp of incoming events are automatically available for this, but for everything else you need to have a user trait or event property with the datatype “datetime”, in order for the system to be able to process the information accordingly.
If you are not sure what datatype a specific user trait or event property has, you can always see it in the selection in the segment conditions on the right side:
Notations
Usually datetime attributes are used in relative form instead of very specific dates, e.g. in a week, 3 weeks ago etc. This can be done with some shortform notations: d for days, w for weeks, y for years and + or - to specify, if you want to look into future or past dates.
The app will show you a little tooltip underneath that tells you what exact date this would be right in that moment and to the exact minute (and technically even second, even if its not shown).
Here are some examples that were made on 20 Apr 2023 in the morning:
exactly one week from now
exactly one year from now
exactly one day from now (+ is not necessary in this case)
one year and 4 weeks from now
one year and for weeks in the past
one year, for weeks and 3 days in the past
this counts one year back, adds 4 weeks and substracts 3 days again
you can also state the year, but it will not be the whole year, but todays date (days, month, minutes, seconds) in that year
exact date
Timeframes
When it comes to timeframes (e.g. “within the last 3 weeks”, “between X and Y” etc.) it gets a bit tricky, because you need to remember, that it always refers to a specific time in the past or future.
“is less or exactly” means in this case, that the system looks at the date (e.g. -1d, which would be yesterday) and before that (e.g. yesterday or longer ago).
“is more or exactly” is the opposite, so it will look at the date and after that (+1d would be tomorrow or more into the future)