Dash Range Slider with date


I want to create a range slider from Jan 2018- Jan 2019. I have a column df[‘AUDITTIME’] where the date is a timestamp in this format 2019-01-04 14:00. What I need is a min Value of Jan 2018 and Max value of Jan 2019 and the range slider will be updated if the user what to narrow the month range. So I need the min, max value for the callback.
The problem is that the values is only a number so I do not know how to convert them and how to implement the marks.


Firstly, I am a little confused with your question - Do you want the minimum timestamp of January-2018 and the Maximum timestamp of January-2019? Or do you want the minimum and maximum timestamps of your data-set from the columns AUDITTIME? I’ll try to answer from both assumptions.

For the First One, if you have pandas imported, you can generate the minimum timestamp of Jan-2018 as pandas.Timestamp(2018, 1, 1, 0), and similarly the max timestamp of Jan-2019 as pandas.Timestamp(2019, 1, 31, 23, 59, 59). On the python interpreter it looks like Timestamp('2018-01-01 00:00:00') and Timestamp('2018-12-31 23:59:59') respectively.

For the Second one, you can again simply use pandas and pass the arguments to dcc.Slider() like so - dcc.Slider(min=df['AUDITTIME'].min().day, max=df['AUDITTIME'].max().day, value=df['AUDITTIME'].min().day, marks = {date.day:date.day for date in df['AUDITTIME'].dt.date.unique()})

I hope I answered you. Please let me know if not.


I want the minimum and maximum from the colum Audittime but the min woul be Jan18 and max Jan19. I want the range slider to show every month and year from jAN18 to now. The range slider you have created is based only on date and not on month/year basis.


I want every month to be displayed JAN18, Feb18, Marz18…, Dec18,Jan19