I used a connection string for ;DateTimeKind= DateTimeKind.Utc but my inserts are still incorrect:
"91","Eric","Schneider","Paul","11/27/1972 12:00:00 AM","1" I don't think the inserts for parameter are formatting the date. I don't believe this is UCT format. I have also confirmed that my UI that I use to display the data does not alter the date format. -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Joe Mistachkin Sent: Wednesday, May 29, 2013 10:58 PM To: 'General Discussion of SQLite Database' Subject: Re: [sqlite] .net Sqlite lib reading date fields not working? Eric Schneider wrote: > > That's. For parsing, what about inserts? > 5/25/2013 1:18:20 PM The new connection string property should apply to any operation that requires converting a string to a DateTime or vice-versa (e.g. parsing or formatting). When inserting a row using a parameterized INSERT statement and a strongly typed parameter containing a DateTime, the actual DateTime object will be converted to a string prior to being physically inserted into the database. The parameters governing this conversion process are the DateTimeFormat (enum), DateTimeKind (enum), and DateTimeFormatString (string). By default, the DateTimeFormat (enum) is set to ISO8601, which will not be suitable for strings with a format like "5/25/2013 1:18:20 PM" (i.e. from your original message). Here are some possible solutions to your issue: 1. Set the DateTimeFormat connection string property to CurrentCulture. This is much more relaxed than ISO8601. Set the DateTimeKind to either Utc or Local, depending on which time zone your DateTime values are from. 2. Set the DateTimeFormatString to something that will be able to parse the DateTime values you have (e.g. "M/d/yyyy h:mm:ss tt"). Again, you will also want to set the DateTimeKind to either Utc or Local. 3. Combine #1 and #2. Set DateTimeFormat to CurrentCulture, DateTimeKind to Utc or Local, and DateTimeFormatString to "M/d/yyyy h:mm:ss tt". If none of the above work, there are some additional troubleshooting steps you can take to determine EXACTLY how parameter values are being bound to your statement (e.g. via the LogBind connection flag, which can also be enabled via the connection string). The documentation contains full details on the possible connection flags and their effects. -- Joe Mistachkin _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users