Skip to content
Advertisement

Compare date of input type datetime with date in SQL using flask

I use this .html page to get input type datetime:

And my .py code:

my DB:

DB Example

I want to show only all data of ‘sessioncreate’ when only date of ‘sdate’ equal of today date

How can i achieve that?

Advertisement

Answer

Use the DATE() function. This way you can convert the DATETIME in your database to DATE and easily compare.

cursor.execute('SELECT * FROM sessioncreate WHERE DATE(sessioncreate.sdate) = %s',(today_date))

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement