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

  • SEARCH
  • Home
  • 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 6153339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:04:42+00:00 2026-05-23T20:04:42+00:00

background: We recently upgraded to handle UTC. ie., went thru each sp and func

  • 0

background: We recently upgraded to handle UTC. ie., went thru each sp and func and changed the t-sql code to handle utc. For eg., changed getdate() to getutcdate() etc. For new shipments we are good where the db is blank. For our older customers who want to keep their data we need to run a script that will update all the dates to utc. I am about to code in t-sql something like below and want to know if this is best way. Below is pseudo code. thanks

foreach (table in mydb.tables())
{
  foreach (column col in table)
  {
      if (col.type == datetime)
      {
           update table set col = fn_convert_date_to_utc(col)
      }
  }
}
  • 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-05-23T20:04:43+00:00Added an answer on May 23, 2026 at 8:04 pm

    Assuming you know the offset between UTC and the timezone the data is stored in, it’s pretty simple:

    DECLARE @offset INT;
    SET @offset = <offset>;
    UPDATE table SET col = DATEADD(HOUR, @offset, col);
    

    Note that might be negative or positive, I have no idea which side of Greenwich you are.

    Of course this gets more complicated if you are in a timezone that observes daylight saving time; in this case you may need a more expansive solution such as using a calendar table. This is particularly complex if your data extends back before George Bush changed the American DST rules, for example. I do have an article from a long time ago that may be useful; a more recent series is here:

    • Handle conversion between time zones in SQL Server – part 1
    • Handle conversion between time zones in SQL Server – part 2
    • Handle conversion between time zones in SQL Server – part 3

    Also if any of your data falls in that window between 12:00 AM and 2:00 AM on a spring forward/fall back day, where I am never sure whether it is right to change it because it’s the changeover day or to not change it because it’s before 2 AM.

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

Sidebar

Related Questions

Little background: Recently I upgraded SQL server management studio 2005 by applying the patch
The Background (skip to the bottom if you want the question) Recently I upgraded
Background: I recently completed a tic-tac-toe game in AS3, using some simple function-based code
My database background is mainly Oracle, but I've recently been helping with some SQL
I had written this code out using Adobe CS3 and have recently upgraded to
EDIT: Using simpler code. I have a blackberry app that until recently (I upgraded
I have a background in LAMP development and have recently started learning sql server.
Background info I recently handed in an assigment for my class on algorithms and
Background info: I've recently decided to take on a project of making a social
I recently got into Java. I have a background in dynamic languages and I'm

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.