C++ 如何选择SQLite日期格式
Sqlite在存储时间方面与其他数据库不同:C++ 如何选择SQLite日期格式,c++,database,database-design,sqlite,C++,Database,Database Design,Sqlite,Sqlite在存储时间方面与其他数据库不同: SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values: **TEXT** as ISO860
SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:
**TEXT** as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
**REAL** as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar.
**INTEGER** as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC.
Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.
在sqlite数据库中存储日期数据的最佳方法是什么?。文本,实数还是整数?我感兴趣的是“使用文本会占用空间,使用整数很好,但2038年会有一个大问题”
- 自SQLite 3.0以来,整数存储在64位上,因此2038年并不是一个真正的问题
- 对于实数或整数,插入时必须以天或秒为单位执行计算。使用Integer时,分辨率为1秒。对于文本,它是一毫秒
- 自SQLite 3.0以来,整数存储在64位上,因此2038年并不是一个真正的问题
- 对于实数或整数,插入时必须以天或秒为单位执行计算。使用Integer时,分辨率为1秒。对于文本,它是一毫秒
如果不需要秒的分数,最简单的方法是历元(1970-01-01 00:00之前或之后的整数秒数),精确到-4714-11-24到5352-11-01 10:52:47
对于人类可读日期的计算,有一个函数如果不需要秒的分数,最简单的方法是历元(1970-01-01 00:00之前或之后的整数秒),精确到-4714-11-24到5352-11-01 10:52:47
要计算人类可读的日期,有一个函数您需要datetime还是只需要date?您需要datetime还是只需要date?