C++ 如何选择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在存储时间方面与其他数据库不同:

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秒。对于文本,它是一毫秒
如果您关心的是总空间,并且在1970年之前不需要任何毫秒或日期,那么选择整数。

  • 自SQLite 3.0以来,整数存储在64位上,因此2038年并不是一个真正的问题
  • 对于实数或整数,插入时必须以天或秒为单位执行计算。使用Integer时,分辨率为1秒。对于文本,它是一毫秒
如果您关心的是总空间,并且在1970年之前不需要任何毫秒或日期,那么请选择整数。

这是否正确

Format Resolution Min Year Max Year Bytes/Date Text Milliseconds 0 AD 9999 AD 23 or 46 Real Milliseconds? 4713 BC ???? 8 Integer Seconds 1970 AD ???? 8 格式分辨率最小年份最大年份字节/日期 文字毫秒0 AD 9999 AD 23或46 真正的毫秒?公元前4713年????8. 整数秒1970广告????8. 这是正确的吗

Format Resolution Min Year Max Year Bytes/Date Text Milliseconds 0 AD 9999 AD 23 or 46 Real Milliseconds? 4713 BC ???? 8 Integer Seconds 1970 AD ???? 8 格式分辨率最小年份最大年份字节/日期 文字毫秒0 AD 9999 AD 23或46 真正的毫秒?公元前4713年????8. 整数秒1970广告????8.
如果不需要秒的分数,最简单的方法是历元(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?