Negative dates in SQLite

倾然丶 夕夏残阳落幕 提交于 2019-12-08 13:46:19

问题


Newly compiled SQLite displays a strange behavior concerning the date/time functions. Do you have any idea what is going on and how to fix it?

    $ date
    Mon Mar  8 14:52:11 CET 2010

    $ ./sqlite3 TEST0
    SQLite version 3.6.22
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> SELECT date('now');
    -4713-11-24

    sqlite> SELECT strftime('%s','now');
    -210866760000

    sqlite> select datetime( -210866760000 , 'unixepoch');
    1970-01-01 00:00:00

The version is SQLite 3_6_22 for ARM-Linux. I'm not sure...maybe some crosscompilation problems?


回答1:


Looks like SQLite can't access the clock for some reason so it's assuming a date of zero. It uses the Julian Day for its internal date represenation, so this converts to -4713-11-24 12:00:00.




回答2:


...make sure the compilation is adjusted for your specific model of ARM ( -mtune=arm920t ) instead of just generic armel, arm9 and the likes. Otherwise the program works okay in general, but doesn't get access to various features like the clock...



来源:https://stackoverflow.com/questions/2401804/negative-dates-in-sqlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!