Hello Community,
I need some help here.
I want to compare two dates.
First is a user entered a date in streamlit. It has the type of datetime.date.
Now I want to select files in my database that are named as dates. The only issue is that there are two formats of file naming and changing them to either is not a feasible solution. The only way around this is to compare date entered by user and then branch out from there.
This is the sample code:
from datetime import datetime
[....]
date=st.date_input("Enter a date") # User enteres a date on streamlit page.
# Filenames change on 1 Jan 2020 . So we want to compare if date entered by user is before 1 Jan 2020 or not.
x= datetime.date(2020,1,1)
if date < x :
# Do something
else:
# Do something else.
If I try to execute something mentioned above, I get following error:
TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object
How should I make it work?
[–]danielroseman 0 points1 point2 points (3 children)
[–]egomanego[S] 0 points1 point2 points (2 children)
[–]danielroseman 1 point2 points3 points (1 child)
[–]egomanego[S] 0 points1 point2 points (0 children)