4/17/2022, 5:03:31 PM convert into YYYY-MM-DD HH:MM:SS

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

Thanks for replying KenWhitesell it will really help me if you give pseudo code
because I want to store this data into another table. I try strtime in SQL but due to not valid string it returns me a null value