Web service : DT2TIME conversion error

titoffffffftitofffffff Member Posts: 2
edited 2009-11-23 in NAV Three Tier
Hi,

I have an error with DT2TIME function while I use Web Service.

I use this table :
OBJECT Table 50000 testDate
{
  OBJECT-PROPERTIES
  {
    Date=22/11/09;
    Time=01:37:37;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    OnInsert=BEGIN
               tdate := DT2DATE(tdatetime);
               ttime := DT2TIME(tdatetime);
             END;

  }
  FIELDS
  {
    { 1   ;   ;tdate               ;Date           }
    { 2   ;   ;ttime               ;Time           }
    { 3   ;   ;tdatetime           ;DateTime       }
  }
  KEYS
  {
    {    ;tdate,ttime,tdatetime                   ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    BEGIN
    END.
  }
}


I have exposed this table as Web Service using a page.

I use this c# code in order to insert data :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestDate
{
    using TestDate_Service;
    
    class Program
    {
        static void Main(string[] args)
        {
            testWs_Service ws = new testWs_Service();
            ws.UseDefaultCredentials = true;

            testWs t = new testWs();
            t.tdatetime = DateTime.Parse("24/01/1981 10:00:00");
            t.tdatetimeSpecified = true;
            ws.Create(ref t);
            testWs t1 = new testWs();
            t1.tdatetime = DateTime.Parse("24/01/1981 10:00:00").ToUniversalTime();
            t1.tdatetimeSpecified = true;
            ws.Create(ref t1);
            testWs t2 = new testWs();
            t2.tdatetime = DateTime.Parse("24/01/1981 10:00:00").ToLocalTime();
            t2.tdatetimeSpecified = true;
            ws.Create(ref t2);
            
        }
    }
}


When I execute the c# program I have this result in Nav table :
tdate	         ttime	         tdatetime
01/01/80	10:00:00	01/01/80 11:00
02/01/80	09:00:00	02/01/80 10:00
03/01/80	10:00:00	03/01/80 11:00
In this case, server and client are in the same time zone GMT+1.

If I try this configuration :
client : GMT+1
server : GMT

I have this result :
tdate	         ttime	        tdatetime
01/01/80	10:00:00	01/01/80 10:00
02/01/80	09:00:00	02/01/80 09:00
03/01/80	10:00:00	03/01/80 10:00

So, I suppose Web service server must have GMT time zone.

Is there any other solution ? Configuration on Nav Server ?

Thanks :D

Comments

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    So, I suppose Web service server must have GMT time zone.

    You are is correct. Service tier always returns time in GMT, and there is no config for that. The application using (I just don't like work 'consuming') web services must perform conversion to the local (to the calling application) time zone.

    There is good reason for this - how would web service tier serve requests from two or more applications working in two different time zones ?

    Regards,
    slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.