SQLite database DateTime format set to default - how to change this?

I have a SQLite database that I insert data to, the integers return perfectly but I have two dates that unfortunately only return the default format of 01/01/0001 12:00:00AM

This is the code I have, please let me know if I am doing anything wrong

public class FixtureItem
{

    [PrimaryKey, AutoIncrement]
    public int FixtureID { get; set; }

    public int CompetitionID { get; set; }

    public DateTime Date { get; set; }

    public DateTime KickOff { get; set; }

    public int HomeTeamID { get; set; }

    public int AwayTeamID { get; set; }


    public FixtureItem()
    {

    }

    }

public class Fixtures_SQLiteDB
{

    private string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

    public  bool createDataBase()
    {
        try
        {
            using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "SphereSports.db")))
            {
                connection.CreateTable <FixtureItem>();





               connection.Execute("Drop TABLE [Fixture]", "");

                connection.Execute("CREATE TABLE [Fixture] ([FixtureID] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, [CompetitionID] INTEGER NOT NULL, [DATE] INTEGER NOT NULL,[KICKOFF] DATETIME NOT NULL, [HomeTeamID] INTEGER NOT NULL ,[AwayTeamID] INTEGER NOT NULL)", "");
                connection.Execute(String.Format("Insert Into  [Fixture] ([CompetitionID],[Date],[KickOff],[HomeTeamID],[AwayTeamID] ) Values ({0},{1},{2},{3},{4})", "2", "2016 - 01 - 04 14:00:00.000", "2016-01-04 14:00:00.000", "1", "3"), "");
                connection.Execute(String.Format("Insert Into  [Fixture] ([CompetitionID],[Date],[KickOff],[HomeTeamID],[AwayTeamID] ) Values ({0},{1},{2},{3},{4})", "4", "2016-02-04 14:00:00", "2016-02-04 14:00:00", "2", "4"), "");
                connection.Execute(String.Format("Insert Into  [Fixture] ([CompetitionID],[Date],[KickOff],[HomeTeamID],[AwayTeamID] ) Values ({0},{1},{2},{3},{4})", "5", "2016-03-04 14:00:00", "2016-03-04 14:00:00", "5", "7"), "");
                connection.Execute(String.Format("Insert Into  [Fixture] ([CompetitionID],[Date],[KickOff],[HomeTeamID],[AwayTeamID] ) Values ({0},{1},{2},{3},{4})", "1", "2016-04-04 14:00:00", "2016-04-04 14:00:00", "6", "8"), "");
                connection.Execute(String.Format("Insert Into  [Fixture] ([CompetitionID],[Date],[KickOff],[HomeTeamID],[AwayTeamID] ) Values ({0},{1},{2},{3},{4})", "3", "2016-05-04 14:00:00", "2016-05-04 14:00:00", "9", "11"), "");
                connection.Execute(String.Format("Insert Into  [Fixture] ([CompetitionID],[Date],[KickOff],[HomeTeamID],[AwayTeamID] ) Values ({0},{1},{2},{3},{4})", "4", "2016-06-04 14:00:00", "2016-06-04 14:00:00", "10", "12"), "");

                return true;


            }
        }
        catch (SQLiteException ex)
        {
            Log.Info("SQLiteEx", ex.Message);
            return false;
        }

    }

    public List<FixtureItem> selectTableFixtureItem()
    {
        try
        {
            using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "SphereSports.db")))
            {
                return connection.Query<FixtureItem>("SELECT * FROM [Fixture]", "").ToList();

            }
        }
        catch (SQLiteException ex)
        {
            Log.Info("SQLiteEx", ex.Message);
            return null;
        }
    }
}

Answers

Sign In or Register to comment.