Date Object or just a string in database field?

I would appreciate others opinions on whether to put a date object in a SQLite date field or just use a string date in a VARCHAR field and convert it when you need to use it as a date.

Seems it would save an awful lot of nil exception handling when reading the records into textedit fields…

thanks
bill

I always store dates in a date field if I’m going to query the table based on a date.

You can put the date in a textfield by:

textfield.text = rs.field(“my_date”).DateValue.ShortDate

or

textfield.text = rs.field(“my_date”).DateValue.SqlDate

use SQLDATE that way you don’t have to worry if the user changed date format settings… plus SQLDATE is “ORDER BY” compatible

rs.field(“my_date”).DateValue.SQLDate
rs.field(“my_date”).DateValue.SQLDateTime

Internally, in a SQLite DB, all dates are stored as TEXT ISO8601 strings (Like “YYYY-MM-DD HH:MM:SS.SSS”).

I use the Xojo date object as a property in a class, so I have to do nil object checking before attempting to use it for populating my listbox with data. Some fields in my DB may or may not have date data so therefore checking that the date object is not nil is always good programming practice.

Been there done that. I hate Nil Object Exceptions!!

Cheers
Grant