Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8187963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:44:37+00:00 2026-06-07T02:44:37+00:00

I have a datetimeoffset column in a table with varying TZ offsets in the

  • 0

I have a datetimeoffset column in a table with varying TZ offsets in the rows. I’d like to run them all through the ToLocalTime method on the BCL type System.DateTimeOffset (due to Daylight Saving, I can’t just use the SWITCHOFFSET function). The ‘clr enabled’ is already reconfigured.

The ‘brute force’ approach appears to be creating a static class with a static method, something like:

public static class DateTimeUtils
{
    [SqlFunction]
    public static DateTimeOffset ToLocalTimeZone(DateTimeOffset input)
    {
        return input.ToLocalTime();
    }
}

Is there any simpler route that would allow calling the BCL type/method without having to create an assembly in the database just for this?

I was hoping I’d be able to just call a method off of the SQL type, but no such luck. Trying something like this:

DECLARE @foo datetimeoffset = getdate()

select [datetimeoffset]::ToLocalTime(@foo)

… gives

Msg 258, Level 15, State 1, Line 3
Cannot call methods on datetimeoffset.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:44:40+00:00Added an answer on June 7, 2026 at 2:44 am

    No, there isn’t. I came to this conclusion after researching this a lot. Here is my solution to the same problem: https://stackoverflow.com/a/11063348/122718

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old table with a few rows that has a datetime column.
I have a SQL Server table with a CreatedDate field of type DateTimeOffset(2). A
I have a SQL 2008 table with a field called RecDate of type DateTimeOffset
I have a SQL Server DB table that has a column ReceivedDate defined as
I would like to have a list of all the time zones available on
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them
have 2 questions : A computer with 32-bit address uses 2-level page table (9
I have a table of play data that I'm using for a prototype. I'm
The DateTimeOffset property I have in this class doesn't get rendered when the data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.