This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 46929 - Datetime error on
Summary: Datetime error on
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.Data.Sqlite (show other bugs)
Version: master
Hardware: PC Windows
: --- normal
Target Milestone: C9SR0
Assignee: Marek Safar
: 52427 (view as bug list)
Depends on:
Reported: 2016-11-14 15:45 UTC by Marco
Modified: 2017-06-28 15:46 UTC (History)
11 users (show)

See Also:
Is this bug a regression?: Yes
Last known good build:

Bug reproduction test case (12.42 KB, application/x-zip-compressed)
2016-11-25 12:28 UTC, Jurij Rožanec

Description Marco 2016-11-14 15:45:51 UTC
Following the last upgrade of the the xamrin environment is no longer possible to perform the queries, which filter is composed with datetime condition.

While leaving all conditions unchanged:  same source code, same database structure and the data in the tables; the solution compiled with the previous framework (until August 2016) return always the correct records, after install the last framework the query return 0 result.

using (SqliteCommand cmd = conn.CreateCommand())
  cmd.Parameters.AddWithValue("@DATESPED", dtDateSped);
  using (SqliteDataAdapter da = new SqliteDataAdapter(cmd))

=== Xamarin Studio Professional ===
Version 6.1.2 (build 44)
Installation UUID: 8716ded3-7f56-49d6-b5ac-f2c7597eef3f
Microsoft .NET 4.0.30319.42000
GTK+ 2.24.26 (Light theme)
GTK# 2.12.38
=== NuGet ===
=== Xamarin.Android ===
Versione: (Visual Studio Professional)
Android SDK: C:\Users\Giovanni\AppData\Local\Android\android-sdk
Versione di Android supportate:
4.0.3  (livello API 15)
4.4    (livello API 19)
4.4.87 (livello API 20)
5.0    (livello API 21)
5.1    (livello API 22)
6.0    (livello API 23)
7.0    (livello API 24)

Versione degli strumenti SDK: 25.2.2
Versione degli strumenti della piattaforma SDK: 25
Versione degli strumenti di compilazione SDK: 23.0.3
Comment 1 Jurij Rožanec 2016-11-25 12:28:12 UTC
Created attachment 18674 [details]
Bug reproduction test case

Test case that reproduces bug under
Mono: 4.6.2
, but not limited to.

Test case passes under
Mono: 4.4
, and earlier versions
Comment 2 Matthew Leibowitz 2017-02-10 22:40:21 UTC
This is a bug, and is a result of these two commits:

These are the related issues:

Basically, the way in which dates are saved was changed:
OLD: yyyy-MM-dd HH:mm:ss.FFFFFFF
NEW: yyyy-MM-dd HH:mm:ss.FFFFFFFK

For whatever reason this was changed, it is "incorrect" with regards to SQLite docs:

> SQLite does not have a storage class set aside for storing dates and/or times.
> Instead, the built-in Date And Time Functions of SQLite are capable of storing 
> dates and times as TEXT, REAL, or INTEGER values:
>   - TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
>   - REAL as Julian day numbers, the number of days since noon in Greenwich on
>     November 24, 4714 B.C. according to the proleptic Gregorian calendar.
>   - INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC.
Comment 3 Marek Safar 2017-02-24 15:27:09 UTC
Fixed in master and upcoming C9 updates
Comment 4 Marek Safar 2017-02-24 15:39:38 UTC
*** Bug 52427 has been marked as a duplicate of this bug. ***
Comment 5 Peter Collins 2017-03-09 20:41:00 UTC
Verified fixed using the attached test case against monodroid/cycle9/3a62f1ea1f6.
Comment 6 Andy Joiner 2017-06-28 15:46:28 UTC
Fix published in Xamarin.Android 7.2

Note You need to log in before you can comment on or make changes to this bug.