Sorting dates in sqlite database?

后端 未结 3 859
清酒与你
清酒与你 2020-12-10 07:55

I have developed an App ..For that I have a database and it has many tables. One of the table has date column. My question is I have to sort the dates and have to pick olde

3条回答
  •  悲&欢浪女
    2020-12-10 08:31

    You can change how it is being stored. Instead of one column, have 3:
    month , day , year ;


    This allows more flexibilityand you can sort it more easily. Since it is numbers month(1-12) instead of strings, it will be more easily sorted.

    SELECT month,day,year
    FROM tables
    ORDER BY month,day,year DESC;
    

提交回复
热议问题