Date conditions
All date conditions can be used either with datetime.datetime or with datetime.date. All examples on this page are using datetime, but can be replaced by date.
before(date): Check if date is before another date
before(date): Check if date is before another dateCheck if a datetime/date is before a given datetime/date.
Stream.of([datetime.now() - timedelta(days=1)])\
.filter(before(datetime.now()))\
.for_each(print) # Output: 2023-06-01 17:03:54.386812after(date): Check if date is after another date
after(date): Check if date is after another dateCheck if a datetime/date is after a given datetime/date.
Stream.of([datetime.now() + timedelta(days=1)])\
.filter(after(datetime.now()))\
.for_each(print) # Output: 2023-06-03 17:03:54.386812before_or_equal(date): Check if date is before or equal to another date
before_or_equal(date): Check if date is before or equal to another dateCheck if a datetime/date is before or equal to a given datetime/date.
Stream.of([datetime.now() - timedelta(days=1)])\
.filter(before_or_equal(datetime.now()))\
.for_each(print) # Output: 2023-06-01 17:03:54.386812after_or_equal(date): Check if date is after or equal to another date
after_or_equal(date): Check if date is after or equal to another dateCheck if a datetime/date is after or equal to a given datetime/date.
between_or_equal(start_date, end_date): Check if date is between or equal to two dates
between_or_equal(start_date, end_date): Check if date is between or equal to two datesCheck if a datetime/date is between or equal to two given datetimes/date.
not_between_or_equal(start_date, end_date): Check if date is not between or equal to two dates
not_between_or_equal(start_date, end_date): Check if date is not between or equal to two datesCheck if a datetime/date is not between or equal to two given datetimes/dates.
today(): Check if date is today
today(): Check if date is todayCheck if a datetime/date is today.
today_utc(): Check if date is today in UTC
today_utc(): Check if date is today in UTCCheck if a datetime/date is today (in UTC).
yesterday(): Check if date is yesterday
yesterday(): Check if date is yesterdayCheck if a datetime/date is yesterday.
yesterday_utc(): Check if date is yesterday in UTC
yesterday_utc(): Check if date is yesterday in UTCCheck if a datetime/date is yesterday (in UTC).
tomorrow(): Check if date is tomorrow
tomorrow(): Check if date is tomorrowCheck if a datetime/date is tomorrow.
tomorrow_utc(): Check if date is tomorrow in UTC
tomorrow_utc(): Check if date is tomorrow in UTCCheck if a datetime/date is tomorrow (in UTC).
this_week(): Check if date is within the current week
this_week(): Check if date is within the current weekCheck if a datetime/date is within the current week.
this_week_utc(): Check if date is within the current week in UTC
this_week_utc(): Check if date is within the current week in UTCCheck if a datetime/date is within the current week (in UTC).
last_week(): Check if date is within the previous week
last_week(): Check if date is within the previous weekCheck if a datetime/date is within the previous week.
last_week_utc(): Check if date is within the previous week in UTC
last_week_utc(): Check if date is within the previous week in UTCCheck if a datetime/date is within the previous week (in UTC).
next_week(): Check if date is within the next week
next_week(): Check if date is within the next weekCheck if a datetime/date is within the next week.
next_week_utc(): Check if date is within the next week in UTC
next_week_utc(): Check if date is within the next week in UTCCheck if a datetime/date is within the next week (in UTC).
this_month(): Check if date is within the current month
this_month(): Check if date is within the current monthCheck if a datetime/date is within the current month.
this_month_utc(): Check if date is within the current month in UTC
this_month_utc(): Check if date is within the current month in UTCCheck if a datetime/date is within the current month (in UTC).
last_month(): Check if date is within the previous month
last_month(): Check if date is within the previous monthCheck if a datetime/date is within the previous month.
last_month_utc(): Check if date is within the previous month in UTC
last_month_utc(): Check if date is within the previous month in UTCCheck if a datetime/date is within the previous month (in UTC).
next_month(): Check if date is within the next month
next_month(): Check if date is within the next monthCheck if a datetime/date is within the next month.
next_month_utc(): Check if date is within the next month in UTC
next_month_utc(): Check if date is within the next month in UTCCheck if a datetime/date is within the next month (in UTC).
this_year(): Check if date is within the current year
this_year(): Check if date is within the current yearCheck if a datetime/date is within the current year.
this_year_utc(): Check if date is within the current year in UTC
this_year_utc(): Check if date is within the current year in UTCCheck if a datetime/date is within the current year (in UTC).
last_year(): Check if date is within the previous year
last_year(): Check if date is within the previous yearCheck if a datetime/date is within the previous year.
last_year_utc(): Check if date is within the previous year in UTC
last_year_utc(): Check if date is within the previous year in UTCCheck if a datetime/date is within the previous year (in UTC).
next_year(): Check if date is within the next year
next_year(): Check if date is within the next yearCheck if a datetime/date is within the next year.
next_year_utc(): Check if date is within the next year in UTC
next_year_utc(): Check if date is within the next year in UTCCheck if a datetime/date is within the next year (in UTC).
Last updated
Was this helpful?