Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do i get the current time in a specific timezone using a query in sql server 2005

Posted on 2010-08-21
2
Medium Priority
?
329 Views
Last Modified: 2012-05-10
I have my web servers hosted in the USA. But i need to display the local time in India.  How do i achieve this. Thanks
0
Comment
Question by:TECH_NET
[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
2 Comments
 
LVL 30

Accepted Solution

by:
Brad Howe earned 2000 total points
ID: 33493828
Hi There,

There is no function for this in SQL 2005 and this is a known issue. Take a look at this table and code to get different timezone stamps.

http://www.codeproject.com/KB/database/SQL2005_TIME_ZONES.aspx

In SQL Server 2008, Microsoft type for datetime called  the datetimeoffset data type.

Cheers,
Hades666
0
 
LVL 41

Expert Comment

by:ralmada
ID: 33501627
I would just use the getutcdate() built-in function to do the job. For example, the below will give you local time in New Delphi, which is UTC + 5:30

select dateadd(min, 30, dateadd(h, 5, getutcdate()))

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
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…

721 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