我正在创建 Android 应用,需要保存创建记录的日期/时间.然而,SQLite 文档说,SQLite 没有专门用于存储日期和/或时间的存储类",并且它能够将日期和时间存储为 TEXT、REAL 或 INTEGER 值".
I’m creating Android apps and need to save date/time of the creation record. The SQLite docs say, however, "SQLite does not have a storage class set aside for storing dates and/or times" and it's "capable of storing dates and times as TEXT, REAL, or INTEGER values".
使用一种类型而不是另一种类型是否有技术原因?单列是否可以以三种格式中的任何一种从行到行存储日期?
Is there a technical reason to use one type over another? And can a single column store dates in any of the three formats from row to row?
我稍后需要比较日期.例如,在我的应用中,我将显示在日期 A 到日期 B 之间创建的所有记录.我担心没有真正的 DATETIME 列可能会使比较变得困难.
I will need to compare dates later. For instance, in my apps I will show all records that are created between date A until date B. I am worried that not having a true DATETIME column could make comparisons difficult.
SQlite 没有特定的日期时间类型.您可以使用 TEXT
、REAL
或 INTEGER
类型,以适合您的需要.
SQlite does not have a specific datetime type. You can use TEXT
, REAL
or INTEGER
types, whichever suits your needs.
SQLite 没有专门用于存储日期和/或时间的存储类.相反,SQLite 的内置日期和时间函数能够将日期和时间存储为 TEXT、REAL 或 INTEGER 值:
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:
应用程序可以选择以任何这些格式存储日期和时间,并使用内置的日期和时间函数在格式之间自由转换.
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 内置日期和时间函数可以在这里找到.
SQLite built-in Date and Time functions can be found here.
这篇关于DATETIME 值如何在 SQLite 中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!