Optimal way to store datetime values in SQLite database (Delphi)

后端 未结 5 1374
无人及你
无人及你 2021-02-08 16:29

I will be storing datetime values in an SQLite database (using Delphi and the DISqlite library). The nature of the db is such that it will never need to be transferred between c

5条回答
  •  佛祖请我去吃肉
    2021-02-08 16:29

    For this I usually use an Integer data type and store the Unix timestamp value alike (eq # seconds since 1-1-2000 for example). Calculating this t/from a TDateTime is equal to multiplying/diving with/by 86400 and adding a constant for the 'since'.

    If you need more precision You could use the DateTime as a FILETIME (eg int64) which has 100 ns increments. There are conversion routines in SysUtils for that and your timestamp is stored in UTC.

提交回复
热议问题