In my SQLite table, I have two columns jointime and leavetime and both column’s values store ‘4/17/2022, 5:03:31 PM’ format and want to convert into ‘2022-04-17 17:03:31’ SQLite date format
That’s probably something you could do easily enough with the Django shell.
Write a for
loop to read all the rows in the table, use strptime to convert the values coming in a datetime field, then use strftime to write the values back out.
You probably could also do this using a single UPDATE
statement in the sqlite shell, but I’m not familiar enough with the datetime functions in sqlite to recommend anything.
1 Like