How to convert milliseconds to date in SQLite

后端 未结 3 1759
一整个雨季
一整个雨季 2020-12-01 12:32

I store date from Calendar.getTimeInMilliseconds() in SQLite DB. I need to mark first rows by every month in SELECT statement, so I need convert time in milliseconds into an

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 13:12

    Do you need to avoid milliseconds to date conversion or function to convert milliseconds to date? Since sqlite date functions work with seconds, then you can try to

    • convert milliseconds in your query, like this
      select date(milliscolumn/1000,'unixepoch','localtime') from table1
    • convert millis to seconds before saving it to db, and then use date function in sql query

提交回复
热议问题