Local Time / Server Time / What Time Zones

Hello Everyone - I need to know what the “absolute” time is within c/side. Meaning, I need to know if it’s 3:00pm in the PACIFIC time zone. I have users connecting over Citrix and if I look at the local time, I don’t know what time zone they are in. Here are some thoughts I have, but don’t know how to go about each one; -Can I find the SERVER TIME - since I know where the server is, I would know the “absolute time” -Is there a Windows variable that refrences the time zone? For example, I have used this code before to the the temp directory; txtTempPath := ENVIRON(‘temp’); which gives me the Temp variable - does one exist in windows for Time Zone? Any other suggestions are welcome. Thanks, Mike

On SQL server the Time is stored in Greenwich time (UK) time. Navision client then changes the value based on windows setting. So if a user in pacific time zone enters time, at 3pm, a user in eastern zone will see the time 12:00 pm. I hope I’m making sense. If this doesn’t solve your issue, you can always add a field to user setup table for time difference. So you can add or subtrack based on how the user is setup. Hope this helps

Hi Ahmed, thanks for the reply but I still don’t understand exactly how I can tell the time and time zone. Maybe you can provide a code example? I need to access it from C/Side and the users travel so it won’t be the same all the time. Thx, Mike

This behaviour is only for the DateTime data type, since it is a UTC data type but the regular Time field uses local time always. The DateTime is available on both servers - its not anything about how it is stored in SQL because SQL has no UTC concept. It sounds like the DateTime is what you’re looking for, although it does not store the timezone - only the date and time.

If you don’t mind a little poking around in the Registry, you can ‘roll your own’ time-zone stuff:

// ------------------------------------------- // ref: http://support.microsoft.com/kb/221542 // ------------------------------------------- CREATE(wshShell); // get 'active' time bias... intActiveTimeBias := wshShell.RegRead( 'HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias'); // get base bias... intBias := wshShell.RegRead( 'HKLM\System\CurrentControlSet\Control\TimeZoneInformation\Bias'); // get standard bias and name... intStandardBias := wshShell.RegRead( 'HKLM\System\CurrentControlSet\Control\TimeZoneInformation\StandardBias'); txtStandardName := wshShell.RegRead( 'HKLM\System\CurrentControlSet\Control\TimeZoneInformation\StandardName'); // get daylight bias and name... intDaylightBias := wshShell.RegRead( 'HKLM\System\CurrentControlSet\Control\TimeZoneInformation\DaylightBias'); txtDaylightName := wshShell.RegRead( 'HKLM\System\CurrentControlSet\Control\TimeZoneInformation\DaylightName'); CASE intActiveTimeBias OF intBias + intStandardBias: txtCurrTimeZone := txtStandardName; intBias + intDaylightBias: txtCurrTimeZone := txtDaylightName; ELSE txtCurrTimeZone := '(?)'; END; timLocalTime := TIME; timUTCTime := timLocalTime + (intActiveTimeBias * 60000); timPacificTime := timUTCTime - (8 * 60 * 60 * 10000); MESSAGE( 'Your machine''s current time zone is ''%1''.\\' + 'The local machine time is %2.\\' + 'If this is reasonably correct, then:\\' + ' - UTC time is %3, and\\' + ' - Pacific time is %4.', txtCurrTimeZone, timLocalTime, timUTCTime, timPacificTime); CLEAR(wshShell);

I forgot to mention the functions around DateTime like CURRENTDATETIME, DT2DATE, DT2TIME etc.

Hi, Sounds like you would need to have comparison between timestamps or something similar. Would it help if you set all the userprofiles in citrix to the same timezone therefore having all users in same time regardless of where they reside? Just a thought. Thanks, Tero

There is also a simpler approach which I have used to find clients in different timezones. Create a datetime field in a setup table, i.e. company information, called “Servertime (01-01-2000 12:00)” and assign it this value for all companies. You can then get the difference between client and server timezone like this: ClientTimezoneDifference() : Duration CompInfo.get; CompInfo.testfield("Servertime (01-01-2000 12:00)"); exit(CompInfo."Servertime (01-01-2000 12:00)" - createdatetime(01012000D,1200T)); Not tested, but I’m sure you get the idea :wink:

Hi PJD, I tried what you suggested, but it didn’t seem to work. It returns that the difference is Zero. Any other suggestions? Are you using this in a production envornment (for actual clients) right now? Thanks, Michael

It works fine in my Navision 3.70 Native DB. Are you using SQL? I’m normally in GMT+1, and when I switch to GMT it returns “-1 Hour”. I don’t have to restart the client or anthing. Just press Apply in the Windows Timezone window and it have effect right away. Does this mean that the datetime field you created doesn’t change automatically when changing timezone. Could you please try in a Native db, it is easier than me installing the SQL :wink:

Got it! Works great many thanks…

Glad to be of service [8D] But could you (or someone else?) please confirm that it works the same using SQL?

Jeps, I did it using SQL…

!!! MAYDAY MAYDAY !!! Insure you change the content of the field when the server switch Daylight saving, or you will get incorrect results !!! Anyone with a better solution???