Re: Client time zones and datetime fields
Posted in 1997
BellSouth wrote: > > Hello all, > > We have a client application in the Eastern Time zone, and is > communicating with a backend server is the Central Time zone. How do we > display the contents of a datetime field in EST - they are all coming up > as CST no matter what the TZ env variable is set to. We are running > HPUX 10.20 and the client is written in the Motif version of NewEra > (version 1.something). Any help would be appreciated! This is a long standing problem with datetime columns. Datetime simply stores whatever time is passed to it without any indication of the timezone represented. If the column is populated by CURRENT which returns local time based on the timezone the server was started with then local time is stored. The best solution is to write a stored procedure or application function to return a datetime representing GMT for storage purposes then convert this to local time in your application on retrieval. I have a function to convert datetime values to a (struct tm) directly if that will help, though most people just use the ESQL/C function dtfmtasc() to convert to a parse-able string and then parse the output to load the tm structure from there, adjusting for local time. Then you can call the asctime function for display. Alternatively, adjust the returned DATETIME from GMT to localtime in the application by adding an appropriate INTERVAL and print the resulting DATETIME value. Art S. Kagel