rafale
rafale

Reputation: 1735

Inserting timestamps into SQLite

I've got a table with a column "date-taken TIMESTAMP", but I'm not sure on what format SQLite is expecting. How would I need to format "5/3/1999 10:30 PM" before I can insert it into the column above?

Also, how do parameterized queries help with formatting things like this?

Upvotes: 0

Views: 3504

Answers (1)

glibdud
glibdud

Reputation: 7880

SQLite doesn't have an actual date/time type, it simply uses strings. Valid date/time string formats can be found here, in the "Time Strings" section:

http://www.sqlite.org/lang_datefunc.html

As for the second question, I'm not sure there's anything you can do with paramaters to help here. You'd probably want to just write a function that converts from your expected format to an SQLite format.

Upvotes: 2

Related Questions