In Microsoft Dynamics NAV 2009 R2 we have new feature named "Defining the Time Zone for Web Services". You can read about it at http://msdn.microsoft.com/en-us/library/gg502505.aspx . The same feature exists in Microsoft Dynamics NAV 2009 SP1 since build 31926 with KB 2443436. However we have few support requests when NAV developers or users don't know about this feature availability or don't know how to use it.
I will try to describe in samples what results we have with different sets.
This feature is important only when you are using date; time or datetime fields and functions to create it. So I created table which has date; time; datetime and description fields
I created codeunit which will be published to Web Service and we'll call function cr_dateTime to create date = Jan 10[sup]th[/sup] 2011
Time = 3:00:00 PM
And DateTime from these values.
In Visual Studio I created C# application which just runs function from codeunit.
WSDT is reference to my Web Service codeunit
And now came main feature point: In CustomSettings.config file could be added new key: "WebServiceDefaultTimeZone".
Actually there could be few possibilities:
1. Key doesn't exists. Then WS works as before this feature implementation - WS uses UTC time zone
2. Key value is empty. The same as point 1 - uses UTC time zone
3. Key value is "UTC". This is default value in Dynamics NAV 2009 R2. WS uses UTC time zone.
4. Key value is "Server Time Zone". WS will work using server computer default time zone. If you are using any time/date functions in code then this key will get you the same results as code running on Classic Client; RTC or NAS.
5. Use any other value from available time zones constants. You can find it at Microsoft Time Zone Index Values at http://support.microsoft.com/kb/973627 . Actually these values already must be in windows registry and if it doesn't exists there, you will have error during WS start.
Here are few of possible time zones values.
My local time zone is "FLE Standard Time"-GMT+02:00, and we need to remember this during execution. So I'm running function from codeunit using different sets.
So it looks everything clear now. However there are few more points need to be mentioned.
In my samples I created datetime using function CREATEDATETIME(011011D,150000T); But what will happen if I will use function CREATEDATETIME(TODAY,TIME);? Problem is that TIME function also knows about time zones and will use it during calculation.
Look, here is example using different "WebServiceDefaultTimeZone" values, and I set to t_time value from TIME and to d_date value from TODAY. When I did tests it was 11[sup]th[/sup] of Jan 2011 about 10:15 AM morning.
You see differences?
1[sup]st[/sup] entry is by direct codeunit run - my correct time.
2[sup]nd[/sup] entry without key and here comes UTC time.
3[sup]rd[/sup] entry with "Server Time Zone" - my correct time
4[sup]th[/sup] entry with "Standard Central Time" (GMT-06:00) - correct time in that zone (10:21-2:00-6:00).
But look to date_time field - it shows correct time for my zone even everything is different. Why?
It is because datetime uses UTC - look what SQL shows.
1[sup]st[/sup] row - my local time 10:15 - 2:00(my time zone) = 08:15 UTC.
2[sup]nd[/sup] row - UTC time now is 08:18 and the same is in datetime.
3[sup]rd[/sup] row - the same as in 1[sup]st[/sup] row
4[sup]th[/sup] row - local time in that time zone is 2:21 AM; UTC time is 8:21 AM and this is in SQL.
I hope this is clear.
At least you can play with some samples and you will find the way you need to have as result.
These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.
Microsoft Customer Service and Support (CSS) EMEA
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|Опции темы||Поиск в этой теме|