Solved

Hot to Convert UTC Time to DATETIME

Posted on 2002-06-23
5
3,117 Views
Last Modified: 2010-08-05
Hi,

How to convert UTC stored in the database to DateTime
in SQL 2000.

Waiting your answers

Ramesh
0
Comment
Question by:ramesh_khade
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7102282
Please maintain your open questions:
AVoid Entry of URL in Address Bar of Internet Explorer Date: 02/19/2001 05:50AM PST  
http://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20080012
Want to display Rich Text ( Created by Microsoft Word ) on the web pages Date: 05/20/2002 04:00AM PST
http://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20302491
How to display & manipulate ****  Menu ***** Date: 01/30/2001 01:08AM PST  

Thanks,
Anthony






0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7102283
0
 
LVL 35

Accepted Solution

by:
David Todd earned 100 total points
ID: 7125539
Hi,

How have you stored the UTC DateTime?

Have you seen the GetUTCDate() function? It returns a datetime.

In that instance it is a matter of changing the UTC date using DateAdd function

For example ...

declare @UTCDiff     integer
declare @UTCStart     datetime
declare @LocalStart     datetime

declare @Local          datetime
declare @UTC          datetime

select @UTCStart = GetUTCDate(), @LocalStart = Getdate()

select @UTCDiff = -datediff( hour, @UTCStart, @LocalStart )

select @UTC = GetUTCDate(), @Local = getDate()

select @UTC, dateadd( hour, @UTCDiff, @Local ), @Local

There are no doubt better ways to figure out the time zone, but from TSQL I figure this is the quickest ...

Regards
  David
0
 

Expert Comment

by:CleanupPing
ID: 9280265
ramesh_khade:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now