Options

How to get Time diff

bala_7bala_7 Member Posts: 9
edited 2013-11-04 in NAV Three Tier
i am not able to get difference between Start Time & End Time both (Time Datatype) in Nav 2013 Report



DiffTime= "End Time"- "Start Time";

i have taken "DiffTime" also(Data type Time) in Global variable

i am getting below error


Microsoft Dynamics NAV Development Environment


Type conversion is not possible because 1 of the operators contains an invalid type.



Time := Integer


OK




please help me

Comments

  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Time := 0T - (235900T - 230000T);

    Should work...
  • Options
    lvanvugtlvanvugt Member Posts: 774
    Note that substracting times will give you an integer with time in ms.
    IMHO saving this in a variable of data type Time doens't make sense as Time is actually a time instance. The same applies for dates. Substracting dates never will result in a new date.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    lvanvugt wrote:
    Substracting dates never will result in a new date.

    ???
  • Options
    lvanvugtlvanvugt Member Posts: 774
    lvanvugt wrote:
    Substracting dates never will result in a new date.

    ???

    8)
    Simple as it is: "November 4 (2013)" - "October 4 (2013)" wil not give me a date. It will will give me a number of days between these two dates.
    Same applies to "times" (or better said: time instances): 14:00 - 13:24 will give the time (length) between these two time instances, being 36 minutes (or it's equivalent in whatever time dimension you use).
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I don't understand why you think a delta between dates or times cannot be used for a new date or time.

    I do it all the time. I spend a lot of time in the logistics business.
  • Options
    bala_7bala_7 Member Posts: 9
    Hi Mark Brummel,

    Thanks for reply,
    DiffTime is Time Data type in NAV 2013 Report
    DiffTime:=0T-("Service Header"."Finishing Time"-"Service Header"."Starting Time");

    it is not working, am getting below error
    Microsoft Dynamics NAV

    The time is not valid.
    OK
    Pls help me
  • Options
    lvanvugtlvanvugt Member Posts: 774
    I don't understand why you think a delta between dates or times cannot be used for a new date or time.
    I do it all the time. I spend a lot of time in the logistics business.
    I don't say it cannot be used, I only point out why the delta itself is not a Time value (and that the same applies to dat substraction).
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Options
    okioki Member Posts: 46
    Hi,
    your term results in a negative value
    try ... := 0T + (...)

    Oli
  • Options
    bala_7bala_7 Member Posts: 9
    Hi OKl,
    Thanks for reply


    Time1:= 0T + (031000T - 030000T);
    MESSAGE('%1',Time1);

    its not working ,am getting same error i.e time is not valid
    please help me
  • Options
    DuikmeesterDuikmeester Member Posts: 304
    Time1 := "Service Header"."Finishing Time";
    Time2 := "Service Header"."Starting Time";
    Duration1 := Time1 - Time2;
    MESSAGE('Duration: %1',Duration1);
    Integer1 := Duration1;
    MESSAGE('Milliseconds: %1',Integer1);
  • Options
    bala_7bala_7 Member Posts: 9
    Hi Duilkmeester,
    Thanks for reply, its working fine but if put any filler like Posting Date its gives error message
    i.e. The Date not valid
    please help me
Sign In or Register to comment.