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

后端 未结 5 1270
无人及你
无人及你 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:50

    You could use one of the SQLite supported string formats, eg. YYYY-MM-DD HH:MM:SS.SSS.

    It would be just as easy as YYYYMMDDHHNNSS - you still wouldn't need to scan for separators, since all the numbers are fixed length - and you would get SQLite date function support.

    If you need SQLite date function support, I would go with that method.

    If not, I'd recommend using REAL values. You can still compare them to each other (higher numbers are later in time), and consider date and time separately (before and after the decimal point respectively) without converting to TDateTime.

提交回复
热议问题