Search code examples
sqlitedate-format

How to change date format in sqlite database


How do I change the format of a date in %d/%m/%Y or any other from this string 10/09/2016 in sqlite?

I have tried this but it is not working:

select strftime('%d/%m/%Y', '09-10-2016'),t_date from party_trans 

Solution

  • try this query

    select strftime('%d/%m/%Y',datetime(substr(t_date, 7, 4) || '-' || substr(t_date, 4, 2) || '-' || substr(t_date, 1, 2))) from party_trans;