Compare dates (stored as string) in android sqlite database?

后端 未结 5 1095
不知归路
不知归路 2020-12-02 19:03

I store dates as String in my database, in this format:

YYYY-MM-DD HH:MM:SS

which is one of supported formats (http://www.sqli

5条回答
  •  一整个雨季
    2020-12-02 19:51

    SELECT *
    FROM MyTable
    WHERE 
        column_date BETWEEN '2000-01-01 00:00:00' AND '2050-01-01 23:00:59'
    

    Should do the trick. This only uses strings but you said that would be fitting.

    The error was the missing time part or not doing a substr on the date part only. And then data/time conversion functions might give wrong things too.

提交回复
热议问题