bvinc / go-sqlite-lite

SQLite driver for the Go programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support Date and Time Datatype

FoxProg opened this issue · comments

How do I get a date and time value from a query result?
There is no official support for date and time types,
but values can be stored in other data types.
https://www.sqlite.org/datatype3.html

go-sqlite-lite should have the same support for DATETIME as sqlite itself. For example, if you decide to store your datetime as the number of seconds since January 1, 1970 UTC, it'll just be up to you to convert your go time.Time to an int64 with t.Unix() and from an int64 to a Time with Time.Unix(sec int64, nsec int64).

I purposely decided not to encode any special meaning or logic into the type DATETIME since sqlite itself does not provide any special meaning to it either, and it would introduce overhead to check it's type, and it's pretty simple to convert the integer yourself.