Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using Local Time Zone wtih SQL Server

Posted on 2011-02-23
4
Medium Priority
?
335 Views
Last Modified: 2012-06-27
I have a date field in an SQL Server 2005 table, and the date is in GMT.  I would like to convert this date field to the local time zone of the user in a SELECT statement.  Currently, all users are on EST, but I would like the flexibility to create this select statement so that if a user on another timezone (PST for example) runs the same query, it will return the date/time in PST.

Is this possible?  If so,how?

Thanks
0
Comment
Question by:jbaird123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 18

Accepted Solution

by:
sventhan earned 2000 total points
ID: 34964442
0
 
LVL 26

Expert Comment

by:tigin44
ID: 34964455
you can use the SWITCHOFFSET
here is an example from books online

CREATE TABLE dbo.test 
    (
    ColDatetimeoffset datetimeoffset
    );
GO
INSERT INTO dbo.test 
VALUES ('1998-09-20 7:45:50.71345 -5:00');
GO
SELECT SWITCHOFFSET (ColDatetimeoffset, '-08:00') 
FROM dbo.test;
GO
--Returns: 1998-09-20 04:45:50.7134500 -08:00
SELECT ColDatetimeoffset
FROM dbo.test;
--Returns: 1998-09-20 07:45:50.7134500 -05:00

Open in new window

0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34964476
0
 

Author Closing Comment

by:jbaird123
ID: 34964573
Thanks!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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