How to make a system time-zone sensitive?
Posted
by
Jerry Dodge
on Programmers
See other posts from Programmers
or by Jerry Dodge
Published on 2012-12-07T17:25:56Z
Indexed on
2012/12/07
17:33 UTC
Read the original article
Hit count: 419
I need to implement time zones in a very large and old Delphi system, where there's a central SQL Server database and possibly hundreds of client installations around the world in different time zones. The application already interacts with the database by only using the date/time of the database server. So, all the time stamps saved in both the database and on the client machines are the date/time of the database server when it happened, never the time of the client machine.
So, when a client is about to display the date/time of something (such as a transaction) which is coming from this database, it needs to show the date/time converted to the local time zone. This is where I get lost.
I would naturally assume there should be something in SQL to recognize the time zone and convert a DateTime field dynamically. I'm not sure if such a thing exists though. If so, that would be perfect, but if not, I need to figure out another way.
This Delphi system (multiple projects) utilizes the SQL Server database using ADO components, VCL data-aware controls, and QuickReports (using data sources). So, there's many places where the data goes directly from the database query to rendering on the screen, without any code to actually put this data on the screen. In the end, I need to know when and how should I get the properly converted time?
There must be a standard method for this, and I'm hoping SQL Server 2008 R2 has this covered...
© Programmers or respective owner