diff --git a/MarkMpn.Sql4Cds.Engine.Tests/ExecutionPlanTests.cs b/MarkMpn.Sql4Cds.Engine.Tests/ExecutionPlanTests.cs index 003c2cf1..c2a20225 100644 --- a/MarkMpn.Sql4Cds.Engine.Tests/ExecutionPlanTests.cs +++ b/MarkMpn.Sql4Cds.Engine.Tests/ExecutionPlanTests.cs @@ -779,7 +779,7 @@ public void GroupByDatePart() AssertFetchXml(aggregateFetch, @" - + @@ -791,7 +791,7 @@ public void GroupByDatePart() AssertFetchXml(partitionFetch, @" - + @@ -844,9 +844,9 @@ GROUP BY AssertFetchXml(aggregateFetch, @" - - - + + + @@ -862,9 +862,9 @@ GROUP BY AssertFetchXml(partitionFetch, @" - - - + + + diff --git a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/HashMatchAggregateNode.cs b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/HashMatchAggregateNode.cs index 98d8c4c4..2e9ed70d 100644 --- a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/HashMatchAggregateNode.cs +++ b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/HashMatchAggregateNode.cs @@ -266,13 +266,6 @@ Source is FetchXmlScan fetch && canUseFetchXmlAggregate = false; break; } - - // FetchXML dategrouping always uses local timezone. If we're using UTC we can't use it - if (!context.Options.UseLocalTimeZone) - { - canUseFetchXmlAggregate = false; - break; - } } } @@ -411,6 +404,8 @@ Source is FetchXmlScan fetch && { attribute.dategrouping = dateGrouping.Value; attribute.dategroupingSpecified = true; + attribute.usertimezone = context.Options.UseLocalTimeZone ? FetchBoolType.@true : FetchBoolType.@false; + attribute.usertimezoneSpecified = true; } else if (grouping.GetType(expressionCompilationContext, out _) == typeof(SqlDateTime)) {