DateTime format in Sqlite

CheegerCheeger RUMember ✭✭

I have db with DateTime fields, in android app, I can only work with them if I change storeDateTimeAsTicks to false, but then I get them in string format("2019-08-10T21:58:13.000"). How do I convert it to DateTime and back to string, to change and return to db?

Best Answers

Answers

  • CheegerCheeger RUMember ✭✭

    @Jarvan said:

    How do I convert it to DateTime and back to string

    Convert string type to DateTime:

    string time_string = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss tt");
    DateTime date = Convert.ToDateTime(time_string);
    

    Convert Datetime type to string:

    string time = oDate.ToString("yyyy/MM/dd hh:mm:ss tt");
    

    It works, but Datetime after converting to string is displayed in SQLite Expert as: 1899-12-30 00:00:00.000.

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited August 15

    This value seems to be what results if there is a date that is deleted.

  • CheegerCheeger RUMember ✭✭
    edited August 15

    @Jarvan said:
    This value seems to be what results if there is a date that is deleted.

    Date is not deleted, just SQLite Expert does not understand this format. This date returns to app as: "2019.08.10 09:33:04 AM" possible somehow turn it into: "2019-08-10T09:33:04.000"?

Sign In or Register to comment.