Time format

  1. 6 days ago

    Arief S

    Feb 12 Bandung - Indonesia

    Hi,

    I have code to do calculating the time,

      Dim BeginDate as new Date
      BeginDate.SQLDatetime= "2020-02-12 17:30:00"
      
      Dim EndDate as new Date
      EndDate.SQLDatetime="2020-02-13 02:00:00"
      
      Dim DateDifference as Double
      DateDifference = EndDate.TotalSeconds - BeginDate.TotalSeconds
      
      Dim DiffDate as new Date
      DiffDate.TotalSeconds = DateDifference
      
      dim gg,dd as integer
      gg=DiffDate.TotalSeconds/3600
      
      MsgBox DiffDate.sqldatetime.NthField(" ",2)

    The result is correct (08:30:00)

    how to convert it into integer, i am expecting the result is 8.5 hours.

    any help ?

    thanks
    regards,
    Arief

    8 would be an integer, 8.5 would be a double, change gg to a Double and you should have the answer you're looking for.

    Dim gg As Double
    gg = DiffDate.TotalSeconds / 3600
    msgbox str(gg)
  2. Julian S

    Feb 12 Pre-Release Testers, Xojo Pro Answer UK

    8 would be an integer, 8.5 would be a double, change gg to a Double and you should have the answer you're looking for.

    Dim gg As Double
    gg = DiffDate.TotalSeconds / 3600
    msgbox str(gg)
  3. Arief S

    Feb 12 Bandung - Indonesia

    thanks

    Regards,
    Arief

or Sign Up to reply!