With the following code, I want to get the start and end date input.
start, end = st.date_input(label='Date Range: ',
value=(datetime.datetime(year=2022, month=5, day=20, hour=16, minute=30),
datetime.datetime(year=2022, month=5, day=30, hour=16, minute=30)),
key='#date_range',
help="The start and end date time",
on_change=lambda : st.write("Start and end date time set!"))
st.write('Start: ', start, "End: ", end)
When prompted, the user clicks on the calendar, there is an error message:
ValueError: not enough values to unpack (expected 2, got 1)
What’s the proper way to get two dates entered? From the documentation st.date_input - Streamlit Docs
it sounds possible to get a tuple of dates.
The alternative works with single item input by one call, but less compact:
start = st.date_input(label='Start: ',
value=datetime.datetime(year=2022, month=5, day=20, hour=16, minute=30),
key='#start',
help="The start date time",
on_change=lambda : None)
end = st.date_input(label='End: ',
value=datetime.datetime(year=2022, month=5, day=30, hour=16, minute=30),
key='#end',
help="The end date time",
on_change=lambda : None)
st.write('Start: ', start, "End: ", end)