How to save and recover a date field in Sqlite3?

Asked

Viewed 1,358 times

1

The point is that on the Sqlite website itself says that for fields date is to use numeric type or string, all right with numeric I write in the bank the date without special characters, however in the string, there’s some way to make a select one-date "12/10/2015" but convert it to a date type to use a between?

  • I believe q saves as string.

1 answer

3


You can use it the 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 simple without formatting or some other numerical form and save as integer even.

If you use a text make sure that the part of greater greatness comes before the part of lesser greatness, as in everything that requires classification, then year comes before month, which comes before day.

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

The between has to be in hand, or create a C auxiliary function that helps you with this and attach it to Sqlite (this can be done in another language if it interoperates well with C.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.