How to save and retrieve a date field in SQLite3?

1

The issue is that in the SQLite site itself says that for date fields is to use numeric type or string , fine with numeric I write in the database the date without special characters, however in the string , is there any way to make a select of a date 10/15/2015 but convert it to a date type to use% ?

    
asked by anonymous 14.01.2016 / 18:04

1 answer

2

You can use it any way you want. SQLite gives you this freedom. Some prefer to format the date as character , something like 20160114 , others prefer to use the timestamp plain or some other numeric form and save as% with% of same.

If you use a text, make sure that the larger part comes first than the smaller part, as in everything that requires sorting, then year comes before month, which comes before day.

Remember that what is in the database is data only. Do not worry about formatting it. Formatting you do in the application the way you think best in each context. Of course it will record in some format, but choose a very simple, like integer .

The yyyymmdd has to be at hand. Or create a helper function in C that will help you in this and attach to SQLite.

    
14.01.2016 / 18:10