You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support the new BCL DateOnly and TimeOnly structs for Sqlite #24506
New DateOnly and TimeOnly structs are being introduced to .NET 6 as alternatives to DateTime (dotnet/runtime#49036). This issue tracks supporting them in Sqlite (both ADO.NET and EF Core providers).
Reacted by Brice Lambson, Erik Ejlskov Jensen, Ryouko Konpaku, Marco Carvalho, Yann Zahringer Ferrando and Pavel Voronin
The DateOnly translations will be the same as the current DateTime translations but using date() instead of datetime().
The TimeOfDay translations will be the same as the ones listed in issue #18844, but using time() (well actually strftime('%H:%M:%f') to preserve precision) instead of ef_timespan(), and julianday() instead of ef_days().
Additional translations:
.NET
SQL
date + time
$date || ' ' || $time
The ADO.NET provider should serialize and deserialize these to TEXT using the hh\:mm\:ss.fff custom format for TimeOfDay and yyyy\-MM\-dd for DateOnly. EF Core literals should use these same formats.
SQLite date and time functions only go to milliseconds. We could allow reading and writing values with higher precision—we do this today for DateTime. But any arithmetic operations on the server will have to truncate. (Unless we add our own UDFs, but IMHO that’s going too far to work around SQLite’s native limitations.)
Please note that the final names for these types are DateOnly and TimeOnly and that they are now merged into the main branch for the next version of .NET 6 (preview 4 likely). Please rename the title of this issue accordingly. Thanks.
changed the title [-]Support the new BCL DateOnly and TimeOfDay structs for Sqlite[/-][+]Support the new BCL DateOnly and TimeOnly structs for Sqlite[/+]on Apr 15, 2021
Activity
bricelam commentedon Mar 26, 2021
The
DateOnlytranslations will be the same as the current DateTime translations but usingdate()instead of datetime().The
TimeOfDaytranslations will be the same as the ones listed in issue #18844, but usingtime()(well actuallystrftime('%H:%M:%f')to preserve precision) instead of ef_timespan(), andjulianday()instead of ef_days().Additional translations:
The ADO.NET provider should serialize and deserialize these to TEXT using the
hh\:mm\:ss.fffcustom format forTimeOfDayandyyyy\-MM\-ddforDateOnly. EF Core literals should use these same formats.bricelam commentedon Mar 26, 2021
On a related note, we should look into updating the
DateTime,DateTimeOffset, andTimeSpanformats to usefffinstead ofFFFFFFF.This would be a breaking change, but also enables us to get rid of the ugly
rtrimcalls in the SQL.mattjohnsonpint commentedon Mar 26, 2021
Why truncate precision to milliseconds?
bricelam commentedon Mar 26, 2021
SQLite date and time functions only go to milliseconds. We could allow reading and writing values with higher precision—we do this today for DateTime. But any arithmetic operations on the server will have to truncate. (Unless we add our own UDFs, but IMHO that’s going too far to work around SQLite’s native limitations.)
mattjohnsonpint commentedon Apr 15, 2021
Please note that the final names for these types are
DateOnlyandTimeOnlyand that they are now merged into the main branch for the next version of .NET 6 (preview 4 likely). Please rename the title of this issue accordingly. Thanks.[-]Support the new BCL DateOnly and TimeOfDay structs for Sqlite[/-][+]Support the new BCL DateOnly and TimeOnly structs for Sqlite[/+]8 remaining items
Implement DateOnly/TimeOnly support for Sqlite
Implement DateOnly/TimeOnly support for Sqlite
Implement DateOnly/TimeOnly support for Sqlite (#24989)