Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. calculate total time "Access"

calculate total time "Access"

Scheduled Pinned Locked Moved Visual Basic
helptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sevan
    wrote on last edited by
    #1

    i am creating a report with Access, i want to calculate the total time spend for example x =Sum([Serv_Rec_Time_Spent]) x is 23:30 H for example, if i add 2 hours then x = 1:30 , instead of 25:30 hours please i need help ASAP

    J 1 Reply Last reply
    0
    • S sevan

      i am creating a report with Access, i want to calculate the total time spend for example x =Sum([Serv_Rec_Time_Spent]) x is 23:30 H for example, if i add 2 hours then x = 1:30 , instead of 25:30 hours please i need help ASAP

      J Offline
      J Offline
      Jim Matthews
      wrote on last edited by
      #2

      in .net you can accomplish this pretty simply using the timespan structure.

      Dim startTime As DateTime
      Dim endTime As DateTime
      Dim duration As TimeSpan
      
      startTime = DateTime.Now
      '--- code to generate your report, or any other process you want to time ---'
      endTime = DateTime.Now
      duration = endTime.Subtract(startTime)
      

      hope this helps,


      -jim

      S 1 Reply Last reply
      0
      • J Jim Matthews

        in .net you can accomplish this pretty simply using the timespan structure.

        Dim startTime As DateTime
        Dim endTime As DateTime
        Dim duration As TimeSpan
        
        startTime = DateTime.Now
        '--- code to generate your report, or any other process you want to time ---'
        endTime = DateTime.Now
        duration = endTime.Subtract(startTime)
        

        hope this helps,


        -jim

        S Offline
        S Offline
        sevan
        wrote on last edited by
        #3

        Well I am not calculating starting time and end time For example I have 10 textbox each one has a different time I just want to add them up so the total will not round up. 20:00 hours Plus 6:00 the total hours should be 26:00, But coz it's time Elapsed, the total is 2:00 hours instead of 26:00 H

        J 1 Reply Last reply
        0
        • S sevan

          Well I am not calculating starting time and end time For example I have 10 textbox each one has a different time I just want to add them up so the total will not round up. 20:00 hours Plus 6:00 the total hours should be 26:00, But coz it's time Elapsed, the total is 2:00 hours instead of 26:00 H

          J Offline
          J Offline
          Jim Matthews
          wrote on last edited by
          #4

          you can still use the timespan structure for this. the only issue is that once you get above 24 hours, the hour portion of the time value is translated into a value representing a day/hour combination. in other words in your example above the resulting value would look like 1.02:00:00 meaning 1 day, 2 hours, 0 minutes, 0 seconds.

          Dim timeOne As DateTime = DateTime.Parse("2004-01-14T12:00:00")
          Dim timeTwo As DateTime = DateTime.Parse("2004-01-14T23:00:00")
          
          Dim totalTime As TimeSpan
          
          totalTime = New TimeSpan(timeOne.TimeOfDay.Ticks + timeTwo.TimeOfDay.Ticks)
          
          messagebox.show(totaltime.tostring)
          

          the result of this example would be 1.11:00:00 (1 day, 11 hours, 0 minutes, 0 seconds) i don't know if this will work for you or not. if you want to post some code maybe i can try to work something else out to help...


          -jim

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups