WebService date format

afarrafarr Member Posts: 287
edited 2012-08-30 in NAV Three Tier
I have a Nav database that is calling a WebService in the same database (this lets me run a report in different companies).
The WebService is using login 'navadmin'.

In Navision, I am entering dates as 31/12/10 (even when I login as navadmin to the machine that is hosting the WebServices and open the RTC), but the WebService is showing this on the report as 12/31/10. In fact, I have to send the date to the webservice as 12/31/10, otherwise I get an error.

How can I change this?

Evidently, navadmin has the settings to view dates as 31/12/10 (both in RTC and Classic)- it's only when running a webservice that it interprets dates as 12/31/10.

There is a previous topic that mentions the User Personalisation table http://mibuso.com/forum/viewtopic.php?f=32&t=38402
All the user personalization records have language ID 1033 (English - US).
However, when I changed this to 2057 (English - UK) on the navadmin record, restarted everything (Nav client, Nav Database Server, webservice), and ran the webservice, the Language ID was re-set to 1033, and reports still showing dates as 12/31/10.
Alastair Farrugia

Answers

  • kinekine Member Posts: 12,562
    How you are calling the WS? Are you using XMLPort, XMLDom or another way?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • afarrafarr Member Posts: 287
    We're using Soap (this was not my choice, but it works).
    Alastair Farrugia
  • afarrafarr Member Posts: 287
    I am using NAV 2009 SP1, not R2.
    There is no WebServicesDefaultTimeZone key in CustomSettings.config
    The registry contains a key for UTC, so it shouldn't be a problem. (The link you mentioned described an issue in R2 where services were starting and then stopping at once - I don't have that problem).

    In any case, I suppose that date format should be independent of the timezone, since there could be people (or at least countries) using different date formats in the same timezone.
    Alastair Farrugia
  • kinekine Member Posts: 12,562
    Ok, you are using soap, it means you are generating the request through the functionality of the Soap Toolkit. How you are formating the data? You should use "FORMAT(mydate,0,9)" to format it into XML format...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • afarrafarr Member Posts: 287
    I tried FORMAT(0,9), but the Soap gave me an error message: "'2010-01-01' is not a valid date."

    I was using FORMAT(StartDate,0,'<Month,2><Day,2><Year><Closing>'), which is accepted because the WebService is formatting dates as 12/31. The issue is why it is doing that when the same user sees dates as 31/12 in both classic and RTC.
    Alastair Farrugia
  • pfancy79pfancy79 Member Posts: 9
    Hi,

    I had a similar issue with dates and webservice calls.
    The answer was setting a record in the User Personalization table. This allows you specify a particular user and the language code that they use. This seems to drive the date format that Navision uses. Does mean that you need a record per user that is going to make web calls.

    Hope this helps.

    Paul
  • afarrafarr Member Posts: 287
    Thanks Paul. Unfortunately, I had tried that and the UserPersonalization."Language ID" field just got reset.

    I had changed it to 2057 (English - UK) on navadmin's record since the Web Service is running as navadmin. I restarted everything (Nav client, Nav Database Server, webservice), and ran the webservice, and the Language ID was re-set to 1033 (English - US), with reports still showing dates as 12/31/10.
    Alastair Farrugia
  • afarrafarr Member Posts: 287
    The dates are now being printed as day/month as required, even when the report is generated through a web service.
    The issue was that I had not properly imported the ENG (English UK) language pack.
      I tried the language import again, imported the language even in Classic client, verified that I could see English (UK) as one of the language options in both Classic and RTC, even when running as navadmin (the user whose login details are used to run the Dynamics NAV Server), made sure that I had the proper files in the Service folder, and restarted the RTC and Web Services.

    The Web Service then printed reports with dates in the required format.
    Thanks to everyone for your help.
    Alastair Farrugia
  • ThramakThramak Member Posts: 1
    Well this is my first post!

    I was also having the same issues with date formatting due to Web Services, the suggestions in this thread worked wonders.

    Thank you very much

    Tony
Sign In or Register to comment.