-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query/Sqlite: AddMonths and AddTicks translation may lead to small result discrepancies vs l2o #25851
Comments
31/10 + 1 month results in 30/11 but on sqlite we translate to 1/12. Moreover, 31/1 + 1 month = 28/2 or 29/2, depending on leap year which might be even more problematic |
tl;dr Sqlite is indeed the odd one out compared to everything else I'm seeing; this is documented as follows:
This seems to correspond to what Jon Skeet describes as "Work out how far we've overshot, and apply that to the next month", where as everyone else does "Round down to the end of the month", see this article for this fascinating subject. So this should be closed as by design (probably unskip the tests and override to pass). Results: PostgreSQLSELECT '2020-10-31'::date + '1 month'::interval; -- 2020-11-30
SELECT '2020-01-31'::date + '1 month'::interval; -- 2020-02-29 SQL ServerSELECT DATEADD(month, 1, '2020-10-31'); -- 2020-11-30
SELECT DATEADD(month, 1, '2020-01-31'); -- 2020-02-29 SqliteSELECT DATE('2020-10-31','+1 months'); -- 2020-12-01
SELECT strftime('%Y-%m-%d', '2020-10-31', '1 months'); -- 2020-12-01
SELECT DATE('2020-01-31','+1 months'); -- 2020-03-02
SELECT strftime('%Y-%m-%d', '2020-01-31', '1 months'); -- 2020-03-02 NodatimeConsole.WriteLine(new LocalDate(2020, 10, 31) + Period.FromMonths(1)); // 2020-11-30
Console.WriteLine(new LocalDate(2020, 1, 31) + Period.FromMonths(1)); // 2020-02-29 .NET DateTimeConsole.WriteLine(new DateTime(2020, 10, 31).AddMonths(1)); // 2020-11-30
Console.WriteLine(new DateTime(2020, 1, 31).AddMonths(1)); // 2020-02-29 |
Sqlite has a peculiar way of adding months, which is by design - we need to compensate in test. Resolves #25851
Sqlite has a peculiar way of adding months, which is by design - we need to compensate in test. Resolves #25851
Sqlite has a peculiar way of adding months, which is by design - we need to compensate in test. Resolves #25851
Sqlite has a peculiar way of adding months, which is by design - we need to compensate in test. Resolves #25851
Tests failing result verification on sql lite:
Select_expression_datetime_add_ticks
Select_expression_datetime_add_month
The text was updated successfully, but these errors were encountered: