Skip to content

Date range picker

ui.DateRangePicker holds a start and an end date. Its popup shows two months: the first click picks the start, the pointer previews the range and the second click picks the end (in any order). The column on the left has quick ranges (today, last 7 days, this week, this month, last month…). on_change receives (start, end) as two datetime.date.

ui.DateRangePicker · Category: Dates and times · Full reference →

Date range pickerDate range picker
  • For reports, filters, stays and anything that spans days.
  • months=1 shows a single month and presets=False hides the quick ranges.
  • The field can be typed too: two dates in format with any separator.
import pyzed as pz
from pyzed import ui
class Report(pz.App):
def __init__(self):
self.period = (None, None)
def view(self):
start, end = self.period
days = (end - start).days + 1 if start and end else 0
return pz.column([
ui.DateRangePicker(value=self.period, format="MMM D, YYYY",
on_change=lambda e: setattr(self, "period", e.value)),
ui.label(f"{days} days selected", color="text_muted"),
], spacing=8, width=300)
Date range picker: months=2Date range picker: months=2
months=2
Code
ui.DateRangePicker(value=("2026-10-05", "2026-10-14"), on_change=on_change)
Date range picker: months=1, presets=FalseDate range picker: months=1, presets=False
months=1, presets=False
Code
ui.DateRangePicker(months=1, presets=False, on_change=on_change)

Date range picker has 3 events of its own, listed below. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.

It is a pz.Component, so it also raises on_mount and on_unmount, and its handlers get a pz.Event whose value holds the data.

Event Handler gets When
on_change (event) Receives event.value: (start, end).
on_open (event) The calendar opened.
on_close (event) The calendar closed.

Handler gets is what Pyzed passes to your callable: () means nothing. Any handler can also be a message (a value that is not callable), which goes to update().

The same events written three ways. Imperative: methods of the app change self. Declarative: the handlers produce messages and one update() decides. Functional: a pure function draws an immutable state and asks for changes with set_state(...). See Imperative, declarative and functional.

class Report(pz.App):
def __init__(self):
self.period = ("2026-10-05", "2026-10-14")
def changed(self, event): # on_change: event.value is (start, end)
self.period = event.value
def view(self):
start, end = self.period
return pz.column([
ui.DateRangePicker(value=self.period, on_change=self.changed),
ui.label(f"From {ui.format_date(start, 'D MMM')} to {ui.format_date(end, 'D MMM')}"),
], spacing=8, width=280)
class DateRangePicker

A component: a field for a start and an end date, with two months and quick ranges (Today, Last 7 days, This month…) in its popup. Typed text is two dates separated by separator. See the Date range picker page.

Property Default Description
value None (start, end): dates, ISO text or None.
format "YYYY-MM-DD" How each date is written.
separator " – " Text between the two dates.
placeholder "" Hint while empty.
min None The earliest date.
max None The latest date.
disabled_dates () Days that cannot be picked.
first_weekday "monday" "monday", "sunday" or "saturday".
months 2 Months shown side by side.
presets True Shows the quick ranges.
clearable True Shows an x that empties it.
disabled False Greys it out.
invalid False Paints the border in the error color.

Events: on_change, on_open, on_close (events).

Full reference →