How to format a datetime MySQL database field to local using strftime()

vergos.nikolas at gmail.com vergos.nikolas at gmail.com
Sun Feb 24 13:03:14 EST 2019


pymydb.execute( '''SELECT host, ref, location, useros, browser, visits, hits, downloads, authuser FROM guests
					WHERE pagesID = (SELECT ID FROM pages WHERE url = %s) ORDER BY visits DESC''', page )
	data = pymydb.fetchall()
        for visit in visits:
              visit = visit.strftime('%A %e %b,  %I:%M %p')


'visit' is being returned from database containing a MySQL datatime field that i want to change to another format which is ('%A %e %b, %I:%M %p') thats why i'm using that function. If not convert or comment out then results are not appearing normally.


More information about the Python-list mailing list