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

Check 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.386812

after(date): Check if date is after another date

Check 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.386812

before_or_equal(date): Check if date is before or equal to another date

Check 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.386812

after_or_equal(date): Check if date is after or equal to another date

Check 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

Check 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

Check if a datetime/date is not between or equal to two given datetimes/dates.

today(): Check if date is today

Check if a datetime/date is today.

today_utc(): Check if date is today in UTC

Check if a datetime/date is today (in UTC).

yesterday(): Check if date is yesterday

Check if a datetime/date is yesterday.

yesterday_utc(): Check if date is yesterday in UTC

Check if a datetime/date is yesterday (in UTC).

tomorrow(): Check if date is tomorrow

Check if a datetime/date is tomorrow.

tomorrow_utc(): Check if date is tomorrow in UTC

Check if a datetime/date is tomorrow (in UTC).

this_week(): Check if date is within the current week

Check if a datetime/date is within the current week.

this_week_utc(): Check if date is within the current week in UTC

Check if a datetime/date is within the current week (in UTC).

last_week(): Check if date is within the previous week

Check if a datetime/date is within the previous week.

last_week_utc(): Check if date is within the previous week in UTC

Check if a datetime/date is within the previous week (in UTC).

next_week(): Check if date is within the next week

Check if a datetime/date is within the next week.

next_week_utc(): Check if date is within the next week in UTC

Check if a datetime/date is within the next week (in UTC).

this_month(): Check if date is within the current month

Check if a datetime/date is within the current month.

this_month_utc(): Check if date is within the current month in UTC

Check if a datetime/date is within the current month (in UTC).

last_month(): Check if date is within the previous month

Check if a datetime/date is within the previous month.

last_month_utc(): Check if date is within the previous month in UTC

Check if a datetime/date is within the previous month (in UTC).

next_month(): Check if date is within the next month

Check if a datetime/date is within the next month.

next_month_utc(): Check if date is within the next month in UTC

Check if a datetime/date is within the next month (in UTC).

this_year(): Check if date is within the current year

Check if a datetime/date is within the current year.

this_year_utc(): Check if date is within the current year in UTC

Check if a datetime/date is within the current year (in UTC).

last_year(): Check if date is within the previous year

Check if a datetime/date is within the previous year.

last_year_utc(): Check if date is within the previous year in UTC

Check if a datetime/date is within the previous year (in UTC).

next_year(): Check if date is within the next year

Check if a datetime/date is within the next year.

next_year_utc(): Check if date is within the next year in UTC

Check if a datetime/date is within the next year (in UTC).

Last updated

Was this helpful?