Skip to content
Advertisement

Convert Date format in SQLite Database

I have a SQLite Database and I mistakenly loaded a lot of data with mismatching date formats. There are dates formatted as: MM/DD/YYYY and dates formatted as: DD-Month Abbr. – YY.

I would really like them all to be YYYYMMDD. Is there a way to reformat all of the dates to match the preferred format?

Thanks!

Advertisement

Answer

If you have only 2 different date formats, you can reformat them by parsing differenly. Follow @MatBailie’s suggestion and use a format supported by Sqlite’s functions, i used YYYY-MM-DD

I decoded MM/DD/YYYY format by finding parts of a date. And than, i decoded DD-Month Abbr. - YY format separately for each Month. 

For MM/DD/YYYY format

For DD-Month Abbr. - YY format

Tested on sqlfiddle.com

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement