streamlit icon indicating copy to clipboard operation
streamlit copied to clipboard

Add datetime input

Open Pydetect opened this issue 2 years ago • 13 comments

Problem

The st.date_input() is not taken into account the time in the widget. We can only select : day, month, year. In order to bypass this limitation, I’m using st.text_input, next I convert it into full datetime format (I don’t want to use st.slider(), It’ s ugly).

image

Solution

The purpose is to add time selection in the widget like this :

image


Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.

If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.

Pydetect avatar Feb 09 '23 20:02 Pydetect

Thanks for sharing this suggestion, @Pydetect ! This is a cool idea. Hopefully, community members will upvote this request so we can prioritize it appropriately.

carolinefrasca avatar Feb 09 '23 21:02 carolinefrasca

We have st.time_input. You can use it in combination with st.date_input to create a datetime input. I know it's a bit annoying to use 2 widgets for such a simple case though 😉 We have a proper datetime input on the roadmap but we probably won't get to it very soon. The problem is that the underlying UI library we use (BaseWeb) does not have a datetime input, so we'd need to do a more complex custom implementation.

jrieke avatar Feb 10 '23 15:02 jrieke

As you said, it's lead to use two widgets, this is exactly what I'm looking to avoid. Everything in streamlit is building from the top to the bottom linearly of the window, less we have widgets, more is better.

One of the high value of streamlit is precely the ergonomy, it's hightlight a clear dashboard. I hope a solution will be find.

Pydetect avatar Apr 05 '23 08:04 Pydetect

+1 to this :)

spencervoorend avatar May 01 '23 07:05 spencervoorend

This would be useful, exactly what I'm looking for right now.

nkilm avatar Nov 19 '23 04:11 nkilm

+1 It's very useful. 😄

weijiany avatar Jan 11 '24 02:01 weijiany

+1. Would be great!

JJFlorian avatar Jan 15 '24 15:01 JJFlorian

  • Is datetime as one input not yet relesed?

poorna243 avatar Jan 23 '24 11:01 poorna243

This would be useful, exactly what I'm looking for right now.

You can use this:

  • pip install streamlit-datetime-range-picker
  • from streamlit_datetime_range_picker import datetime_range_picker
st.subheader('Date Range Picker')
date_range_string = date_range_picker(picker_type=PickerType.time.string_value,
                                      start=-30, end=0, unit=Unit.minutes.string_value,
                                      key='range_picker',
                                      refresh_button={'is_show': True, 'button_name': 'Refresh last 30min',
                                                      'refresh_date': -30,
                                                      'unit': Unit.minutes.string_value})
if date_range_string is not None:
    start_datetime = date_range_string[0]
    end_datetime = date_range_string[1]
    st.write(f"Date Range Picker [{start_datetime}, {end_datetime}]")

The output will look like this. image When you tap on it, it displays this. : image

If you have any questions about Streamlit, please feel free to contact me at any time.Linkedin

ELFALLAH02 avatar Jan 24 '24 15:01 ELFALLAH02

Problem

The st.date_input() is not taken into account the time in the widget. We can only select : day, month, year. In order to bypass this limitation, I’m using st.text_input, next I convert it into full datetime format (I don’t want to use st.slider(), It’ s ugly).

image

Solution

The purpose is to add time selection in the widget like this :

image

Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.

If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.

https://github.com/streamlit/streamlit/issues/6089#issuecomment-1908413981

ELFALLAH02 avatar Jan 24 '24 16:01 ELFALLAH02

This would be useful, exactly what I'm looking for right now.

You can use this:

  • pip install streamlit-datetime-range-picker
  • from streamlit_datetime_range_picker import datetime_range_picker
st.subheader('Date Range Picker')
date_range_string = date_range_picker(picker_type=PickerType.time.string_value,
                                      start=-30, end=0, unit=Unit.minutes.string_value,
                                      key='range_picker',
                                      refresh_button={'is_show': True, 'button_name': 'Refresh last 30min',
                                                      'refresh_date': -30,
                                                      'unit': Unit.minutes.string_value})
if date_range_string is not None:
    start_datetime = date_range_string[0]
    end_datetime = date_range_string[1]
    st.write(f"Date Range Picker [{start_datetime}, {end_datetime}]")

The output will look like this. image When you tap on it, it displays this. : image

If you have any questions about Streamlit, please feel free to contact me at any time.Linkedin

I tried this out - and it flickered my entire screen. Cool idea, not quite ready though.

jennifer-klemisch-pfzr avatar Mar 19 '24 16:03 jennifer-klemisch-pfzr

+1

nikil88 avatar Oct 18 '24 09:10 nikil88

+1 please

anottrott-zipline avatar Oct 18 '24 17:10 anottrott-zipline

+1

sfc-gh-kewang avatar Feb 21 '25 18:02 sfc-gh-kewang

+1

sfc-gh-mneglay avatar Feb 21 '25 18:02 sfc-gh-mneglay

+1

sfc-gh-dbiddle avatar Feb 21 '25 18:02 sfc-gh-dbiddle

+1 PS: Initial comment why this ist not implemented:

The problem is that the underlying UI library we use (BaseWeb) does not have a datetime input, so we'd need to do a more complex custom implementation.

However, BaseWeb has now a Ui component for date + time. See example Calendar with time select actions

joleaf avatar Mar 19 '25 07:03 joleaf

+1

Crudeerz avatar Mar 26 '25 13:03 Crudeerz

+1

Randomboiii03 avatar Mar 28 '25 06:03 Randomboiii03

+1

terrydolan avatar Apr 09 '25 12:04 terrydolan

+1

gRodrigues03 avatar Jun 17 '25 18:06 gRodrigues03

+1

oxyo avatar Jul 23 '25 13:07 oxyo

+1

AliGarAlon avatar Jul 31 '25 11:07 AliGarAlon

Update

Hey all, we just built a prototype for this (see #13014). You can try out the wheel file here. If you try this out, please let us know how it works for you or if there's anything you'd like to see changed. We might need a bit of time to bring this over the finish line because we're busy with other projects, but I hope we'll get it within the next few weeks/months :)

https://github.com/user-attachments/assets/0b3ed263-6cef-4d25-9e88-4931bf1f97b9

jrieke avatar Nov 15 '25 07:11 jrieke

Update

This will be available in the next release (1.52, early December) as st.datetime_input. Let us know if there are any other requests for this!

jrieke avatar Nov 20 '25 04:11 jrieke