Last active
December 23, 2015 04:19
-
-
Save mbylstra/6579686 to your computer and use it in GitHub Desktop.
convert a python date to a mysql date string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import connection | |
from django.db.backends.mysql.base import DatabaseOperations | |
def py_datetime_to_mysql(d): | |
db_ops = DatabaseOperations(connection) | |
return db_ops.value_to_db_datetime(d) | |
#eg: | |
from django.db import connection | |
py_datetime_to_mysql(datetime.now()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment