This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Time Difference between two properties

Hello I need help with creating Time Difference property.

Property Values Examples:

Start Time: 02:57:37 PM
End Time: 02:58:01 PM

I have tried:

Option Explicit

CONST START_TIME_ID = 1213
CONST END_TIME_ID = 1214

dim StartDate_PV: set StartDate_PV = PropertyValues.SearchForProperty(START_TIME_ID)

dim EndTime_PV: set EndTime_PV = PropertyValues.SearchForProperty(END_TIME_ID)

if  ( NOT StartDate_PV.value.IsNull() ) AND ( NOT EndTime_PV.value.IsNull() ) THEN
  output = DateDiff( "d", StartDate_PV.value.value, EndTime_PV.value.value )
else

  output.SetValueToNULL MFDatatypeInteger

end if


But I'm getting Datestamp result: 12/30/1899 1:00 AM

Any solution to this?
  • You have configured Datediff to calculate the difference in days-type interval. You probably want the result to be shown in hours. Try using
    DateDiff( "h", StartDate_PV.value.value, EndTime_PV.value.value )

  • You have configured Datediff to calculate the difference in days-type interval. You probably want the result to be shown in hours. Try using
    DateDiff( "h", StartDate_PV.value.value, EndTime_PV.value.value )



    Thank you for your answer

    I got the same result again with "h" (12/30/1899 1:00 AM).
    I have tried with "n" (which is for minutes) and i got 12/31/1899 1:00 AM

    I really don't understand what is going on here, but i need a solution. :(
    Any help?

  • What is the datatype on your output property?
    Is it configured to be a Text or Number type?
    If you have configured it to be Date or Time that would explain the outcome...

  • What is the datatype on your output property?
    Is it configured to be a Text or Number type?
    If you have configured it to be Date or Time that would explain the outcome...


    Thank you so much!

    It was set to Time type. I changed it to Text now it works perfectly.
    This is already enough for me but it would be nice if i can convert for example result in seconds to time format?
    for example:

    3681 seconds difference to be displayed as 01:01:22 ?
  • Checkout the VBScript Date/Time functions at www.w3schools.com/.../asp_ref_vbscript_functions.asp
    You probably can achieve just that using FormatDateTime, or a concatenation of 3 x DatePart using hour minute and second, or a concatenation of Hour, Minute & Second