I’m modifying some c# code and attempting to add a date+time field to a database when it is created. What would be a good method to do this? I’m new to SQL and databases, so pointing me to helpful resources is also appreciated.
I believe I want something like:
createCommand.CommandText = "CREATE TABLE Table1 ( field1 INTEGER, field2 BLOB, timestamp datatype);"
I am unsure of what datatype to use for a time and date marker. Should I use text and have it be in the form of “12/19/2012, 16:20”? Thanks for the help in advance!
If you are going to use a string type, you should use a format that sorts chronologically in alphabetical order. SQLite’s buit-in functions support ISO 8601 strings (YYYY-MM-DD HH:MM:SS.SSS) as well as Julian day numbers and Unix-style integer timestamps.
See: http://www.sqlite.org/datatype3.html#datetime and http://www.sqlite.org/lang_datefunc.html