Blank date for st.date_input

Hi,

Is it possible to start with a blank date when using the st.date_input?

Use case: when storing dates from a form / several individual date widgets to a database, even the date widgets that the user has not entered default to the current date, which gets updated into the database. Setting the parameter (value=None) does not work.

Would like a solution / hack, if possible,

Thanks in advance,

2 Likes

Hey @Shawn_Pereira -

Your best bet might be to use text_input in this case, and use Python to validate that it’s a valid date before writing to the database. But in general, I agree, would be great to have an ‘optional/none’ value, especially for fields like forms.

Best,
Randy

Thanks @randyzwitch , for your prompt response. I hope Streamlit implements this functionality in the near future - it is already there for a date range, but not for single dates.

Cheers

We were actually thinking about allowing None as a default value for all widgets! Great to hear that this is really needed.

1 Like