how to query in sqlite for different date format

前端 未结 4 1890
北荒
北荒 2020-12-15 06:51

I am using sqlite for local database in mobile and in my database, I have date field with column name RN_CREATE_DATE. My RN_CREATE_DATE

4条回答
  •  天命终不由人
    2020-12-15 07:17

    strftime works like this:

    sqlite> select strftime('%d-%m-%Y %H:%M:%S', datetime('now'));
    2012-09-13 12:42:56
    

    If you want to use it in a WHERE clause, replace datetime('now') with the datetime you want to match in the YYYY-mm-dd HH:MM:SS format.

    Example:

    SELECT *
      FROM t
     WHERE c = strftime('%d-%m-%Y %H:%M:%S', '2012-09-13 12:44:22');
    --                   dd-mm-YYYY HH:MM:SS  YYYY-mm-dd HH:MM:SS
    

提交回复
热议问题