Posted under » MySQL » Python on 20 Mar 2024
MySQL datetime looks like this 2024-03-19 21:07:55.118494. Problem is when you want to do a datetime compare you can't because all you have is string. So you need to import datetime and convert the string into a datetime format.
from datetime import datetime for dog in query: akhir = dog.created tday = datetime(2024,3,16,0) if akhir > tday : print(akhir)
Another example Django API