.NET DateTime appears as Date in Navision

MogMog Member Posts: 34
Hi!

I wrote an automation server in C# that is used by Navision. One method takes a DateTime parameter, but this is displayed as Date in Navision. I am not able to call the method using e.g. CURRENTDATETIME as a value, the compiler starts crying that he wants a Date.

c# code
public class whatever{
  // ...
  public void AddDateTime(DateTime value){
  }

Navision code, unable to compile
create(whatever);
whatever.AddDateTime(CURRENTDATETIME)

Navision code, works
create(whatever);
whatever.AddDateTime(TODAY)

This sucks, as I need the whole information from CURRENTDATETIME to be passed to the automation server. Does anyone have an idea what I did wrong?

regards

Mog

Comments

  • ta5ta5 Member Posts: 1,164
    The types seem get wrongly mapped.
    If the automation object is only used by navision you could try a workaround either by passing date and time separately or passing the value as a text string.

    Good luck.
    Thomas
  • MogMog Member Posts: 34
    thanks, I think I will just hand over a string, but this is really bad :(
  • piktazpiktaz Member Posts: 9
    Hi,

    COMs doesn't support DateTime variables, but does support Variant. The solution below should work.

    c# code
    public class whatever{
      // ...
      public void AddDateTime(System.Object value){
       Datetime dt = DateTime.Parse(value);
       // ...
      }
    

    C/Side code
    // varDateTime  - datatype Variant
    // dteDateTime  - datatype DateTime
    varDateTime := dteDateTime;
    whatever.AddDateTime(varDateTime);
    

    Good luck!
Sign In or Register to comment.