SQL insert DateTime UK and US

I have several client applications (Excel VBA) updating a SQL Server 2008 database from different parts of the world. I have a column for DateTime in DateTime data type. I want to rationalise the DateTime so that a ordering the data in DateTime sequence will be correct. ie. because local time where the users will input from will be different.

So I have decided to use GMT as the standard.

I have these challenges:

(1) To convert local time to GMT.
(2) My server is in the USA. Therefore the data format will need converting?

Any pointers will help me progress. Thanks.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

This nice EXCEL VBA resource has a VBA module with a few handy functions that use the Windows APIs to convert the local time to UTC time. The function ConvertLocalToGMT does the job.

When you call the method to insert the date you need to adjust the local date to UTC using the above function. If you use the parameterised query then you just pass a valid datetime object. However, if you use the normal VBA string query then just convert the date time to the ANSI standard string (YYYY-MM-DD HH:MM:SS) and insert

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
Vitor MontalvãoMSSQL Senior EngineerCommented:
I have a column for DateTime in DateTime data type
In Excel worksheet or in the target database?
For the target column in the database table you can use datetimeoffset data type since it stores the time zone.
hindersalivaAuthor Commented:
Hi, both ideas very useful for me.

I decided to go with a default value for the column . ie. GetDate() for the moment. So I shall store the server's date/time.

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
Microsoft SQL Server

From novice to tech pro — start learning today.