Skip to content

SQL Server basic translations for AT TIME ZONE #26971

Description

@roji

Based on the general support for AT TIME ZONE added in #26199, add some basic SQL Server translations. Note that SQL Server's AT TIME ZONE can accept either a datetime/datetime2 or a datetimeoffset, and always returns a datetimeoffset.

.NET SQL
EF.Functions.AtTimeZone(datetimeoffset, "UTC") datetimeoffset AT TIME ZONE 'UTC'
EF.Functions.AtTimeZone(datetime, "UTC") datetime AT TIME ZONE 'UTC'

Note: there's also DateTimeOffset.ToOffset which can translate to SQL Server SWITCHOFFSET, but SWITCHOFFSET accepts a text expression (+08:00) whereas .NET ToOffset accepts a TimeSpan. Leaving this for now. Same goes for new DateTimeOffset(dateTime, offset) and TODATETIMEOFFSET.

Activity

  1. added this to the 7.0.0 milestone on Dec 12, 2021
  2. self-assigned this
    on Dec 12, 2021
  3. added 2 commits that reference this issue on Dec 12, 2021
    eda6cf0
    f255af3
  4. added a commit that references this issue on Dec 14, 2021
    c74a696
  5. added 2 commits that reference this issue on Jan 12, 2022
    1c5b92a
    5e1dbe5
  6. added 3 commits that reference this issue on May 24, 2022
    2a77f4c
    33df6fc
    2165884
  7. added a commit that references this issue on May 24, 2022
    176f301
  8. modified the milestones: 7.0.0, on May 25, 2022
  9. modified the milestones: , 7.0.0 on Nov 5, 2022
  10. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions