Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite-net datetime retrieval

Hi I have a problem with retrieving datetime from SQLite database using sqlite-net library. Db column is of type DATE, example date in one of records is: 2013-08-02

I have a model:

internal class FCost
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }

    ...

    public DateTime AccountingDate { get; set; }

    ...
}

I execute this line of code:

var result = dc.Table<FCost>().ToArray();

Every field except AccountingDate is filled correctly, all DateTime fields are filled with value: {1/1/0001 12:00:00 AM} (visual studio debbuger view). Why is date not parsed correctly? I tried switching Db column type to DATETIME and TEXT but got same results.

EDIT. Object dc used above is of type SQLiteConnection from sqlite-net library.

like image 519
Jarek Mazur Avatar asked Aug 02 '13 12:08

Jarek Mazur


1 Answers

There is a StoreDateTimeAsTicks property on the SQLiteConnection object that you should use. Set it to 'false'. Worked for me.

like image 139
Alexei Vinidiktov Avatar answered Oct 19 '22 20:10

Alexei Vinidiktov