I understand that Joe, but if I'm inserting using parameters; the Sqlite
.net lib is determining the format not me the developer, I'm just passing in
a DateTime. In fact other people are complaining they cannot insert using
parameters; I assume in that case the specify the check constraint.

I would also state this is an ORM, and this code works for all databases
except Sqlite; Currently Sql Server, Oracle, and MySql. I have work around
the issue, but should not have to.



-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Joe Mistachkin
Sent: Wednesday, May 29, 2013 4:37 PM
To: 'General Discussion of SQLite Database'
Subject: Re: [sqlite] .net Sqlite lib reading date fields not working?


eschneider FE wrote:
> 
> So when using System.Data.SQLite and inserting data using a parameter of
> datetime, I believe the System.Data.SQLite .net lib is doing a ToString()
on
> datetime when it should be using a specific date format supported by
SQlite.
> 

The DateTime parsing and formatting performed by System.Data.SQLite are
governed
by the DateTimeKind and DateTimeFormat properties provided in the connection
string.

The default values are "DateTimeKind.Unspecified" and
"SQLiteDateFormats.ISO8601",
respectively.

When using the ISO-8601 format, the date/time strings must conform to one of
the
"well-known" formats supported by System.Data.SQLite, specifically:

    /// <summary>
    /// An array of ISO-8601 DateTime formats that we support parsing.
    /// </summary>
    private static string[] _datetimeFormats = new string[] {
      "THHmmssK",
      "THHmmK",
      "HH:mm:ss.FFFFFFFK",
      "HH:mm:ssK",
      "HH:mmK",
      "yyyy-MM-dd HH:mm:ss.FFFFFFFK", /* NOTE: UTC default (5). */
      "yyyy-MM-dd HH:mm:ssK",
      "yyyy-MM-dd HH:mmK",
      "yyyy-MM-ddTHH:mm:ss.FFFFFFFK",
      "yyyy-MM-ddTHH:mmK",
      "yyyy-MM-ddTHH:mm:ssK",
      "yyyyMMddHHmmssK",
      "yyyyMMddHHmmK",
      "yyyyMMddTHHmmssFFFFFFFK",
      "THHmmss",
      "THHmm",
      "HH:mm:ss.FFFFFFF",
      "HH:mm:ss",
      "HH:mm",
      "yyyy-MM-dd HH:mm:ss.FFFFFFF", /* NOTE: Non-UTC default (19). */
      "yyyy-MM-dd HH:mm:ss",
      "yyyy-MM-dd HH:mm",
      "yyyy-MM-ddTHH:mm:ss.FFFFFFF",
      "yyyy-MM-ddTHH:mm",
      "yyyy-MM-ddTHH:mm:ss",
      "yyyyMMddHHmmss",
      "yyyyMMddHHmm",
      "yyyyMMddTHHmmssFFFFFFF",
      "yyyy-MM-dd",
      "yyyyMMdd",
      "yy-MM-dd"
    };

The DateTime.ParseExact method is used by System.Data.SQLite; therefore, if
the
DateTime string does not conform to one of the above formats, an exception
will
be generated.

--
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

Reply via email to