【问题标题】:Save and sort date and time in SQLite在 SQLite 中保存和排序日期和时间
【发布时间】:2016-04-22 21:15:37
【问题描述】:

我对这个 qoute 有疑问:

SELECT _id, todo_name, todo_date_start, time_start FROM todo ORDER BY todo_date_start ASC

有没有一种简单的方法可以按开始日期 (dd.mm.yyyy) 和开始时间 (hh:mm) 订购我的待办事项? 它仍然适用于按日期排序。

表格是用文本格式创建的:

COLUMN_DATE_START + " text not null, "
        + COLUMN_TIME_START + " text not null, "

谁能帮帮我?

【问题讨论】:

  • by the start-date (dd.mm.yyyy) and the start-time (hh:mm) 正确的格式是 yyyy-mm-ddThh:mm - 只需要 1

标签: android sqlite date time sql-order-by


【解决方案1】:

试试这个:

SELECT _id, todo_name, todo_date_start, time_start FROM todo 
ORDER BY date(todo_date_start), time(time_start)  ASC

sqlite date and time functions

【讨论】:

  • ASC 可以省略,因为它是默认值
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-26
  • 2021-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多