SQL 2005 - Current time to GMT


I use this code to select the current time.  I have been asked to convert it to GMT, so I need to add 4 hours. How can I do this


Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornSQL Server Data DudeCommented:
If your question is just 'how can I add four hours', then use DATEADD()

Open in new window

If your question is 'How can I convert any given GETDATE() to GMT', then that will imply some math, as we have to figure out what time zone you're in, plus based on that time zone (and local considerations such as US-Indiana or US-Arizona does not participate in Daylight Savings Time) whether or not you are in DST and therefore need to add/subtract an hour.
Nakul VachhrajaniTechnical Architect, Capgemini IndiaCommented:
As long as Daylight Savings Time is not a problem (and if what you really want is UTC, not GMT), the following may help:


Open in new window

JimHorn solution will work, but only if GMT time is four hours ahead (which can be not always true).

If you want to get the current GMT time, just use the function GETUTCDATE():


Open in new window

Hope this helps. Regards.
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

JDCamAuthor Commented:
all good.. but like my sample I need just the time in 24hr format
Jim HornSQL Server Data DudeCommented:
Define 'in 24hr format '.  This article is a real good cheat sheet for date formats.
Try this:


Open in new window

Hope this helps. Regards.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.