0

Time Interval wrong calculation

Hello. I've set the code to calculate the time interval between a dropoff and a pickup. The formula works but for some reason it adds 1 extra hour to the correct calculation..

Can anyone help?

Thanks!

16 replies

null
    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    Have the dropoff and checkout times been recorded in the same time zone, including the DST status? 

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    yes i recorded them both. Does the system somwhow change the time zone?! have no idea of the DST? How do I verify these 2 elements?

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    When saving a Date or a Date/Time, Ninox records the epoch as a number of milliseconds since January 1, 1970, 00:00 UTC, and keeps notice of the current time zone (in iOS, not sure in other environments). When computing the difference between two epochs belonging to different time zones, or to the "Summer time" and the "Winter time" in the same place, the result can be somewhat unexpected.

    To verify the time zone associated with a Date and/or Time value, use the "format" function: format(variableorfield, "Z").

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    Ok. I set both the records, and in the same time zones.

    The problem i belive is that both Checkout Date and Dropoff Date are "Date/Time" fields and the result Storage Duration has to be in hours... how can i solve this?

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    The point is I need to calculate the time interval between 2 Date/Time Field. Do I have to use the Time Interval field? If yes how since the Time Interval has no formula field? I tryed modifing the formula from the table as “Time interval” = “Checkout Date” - “DropOff Date” but no results appear... I get a Yes or No..

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    It depends on the result you need: days rounded, complete days, commenced days...

    In general terms: compute the difference between number() of each value, divide by 86400000 (number of milliseconds in a day), and then apply round(), floor() or ceil().

    Example: floor((number(end)-number(begin))/86400000)

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    i would need to count the time interval in hours

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    hours and minutes..

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    Could you provide an example showing the values of two Date / Time and their incorrect difference?

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    or even just rounded up to closest hour is ok

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    do you want an example of my first inital option format(“Checkout Date” - “Dropoff Date”, “HH:mm”) ?

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view
    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    example

    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view
    • CLD
    • Valerio
    • 3 yrs ago
    • Reported - view

    system doesn“t upload images?!

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    If you cannot upload the image, you could just copy and paste the values of the two Date / Time fields involved, and mention the expected result and actual results.

Content aside

  • 3 yrs agoLast active
  • 16Replies
  • 1236Views