Home > Mobile >  How to add a default date in streamlit date_input
How to add a default date in streamlit date_input

Time:08-05

I have a date input and want to make yesterday as the default date.

import datetime
import streamlit as st

complition_date = st.date_input("Date of completion", datetime.date(2017, 08, 19))

How can I acomplish that?

CodePudding user response:

import datetime
import streamlit as st
from datetime import date, timedelta

today = date.today()

default_date_yesterday = today - timedelta(days=1)

complition_date = st.date_input("Date of completion", default_date_yesterday)
  • Related