New to Kestra?
Use blueprints to kickstart your first workflows.
Gate a daily Kestra Schedule trigger with the DateTimeBetween condition so a flow runs only inside a fixed start and end date window.
id: schedule-condition-datetimebetween
namespace: company.team
triggers:
- id: schedule
type: io.kestra.plugin.core.trigger.Schedule
cron: "0 11 * * *"
when: "{{ trigger.date > '2025-12-31T23:59:59Z' and trigger.date <
'2025-01-01T00:00:00Z' }}"
tasks:
- id: hello
type: io.kestra.plugin.core.log.Log
message: Demo for DateTimeBetween condition
Run a daily cron schedule in Kestra but execute the flow only while the trigger date falls inside a defined start and end window, using the io.kestra.plugin.core.condition.DateTimeBetween condition. This pattern is ideal for time-boxed campaigns, seasonal jobs, promotional periods, or any pipeline that should fire on a regular cadence but only between two calendar dates, without manually enabling and disabling the schedule.
io.kestra.plugin.core.trigger.Schedule trigger fires every day at 11am using the cron expression 0 11 * * *.io.kestra.plugin.core.condition.DateTimeBetween condition that compares {{ trigger.date }} against the before and after bounds.hello task (io.kestra.plugin.core.log.Log) runs and logs a confirmation message.The DateTimeBetween condition also works with either bound alone: provide only before to match any date earlier than that instant, or only after to match any date later than it. Provide both, as in this example, to match dates that fall between the two.
Cron alone tells a job when to attempt a run, but it cannot express a calendar window without external glue. Kestra's trigger conditions add that gating declaratively in YAML, alongside retries, event-based triggers, full execution lineage, and observability. The schedule stays in version control, and the window is auditable in one place rather than scattered across scripts or manual enable and disable steps.
before and after bounds to your target window.hello log task with your real workload.DateTimeBetween with other conditions such as day-of-week or variable checks.