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. Coding issue

Coding issue

Scheduled Pinned Locked Moved Visual Basic
tutorialcsharptoolshelpquestion
6 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
    Sam Heller
    wrote on last edited by
    #1

    I am currently trying to build some code which handles response times. I have a start time, an end time and a response time. Obviously enough the end time is the start time plus the response time. For example Start time 12:00 Response time 6 hours End time 18:00. My issue is finding out if the two times went over no working hours. Mainly lunchtime 13:00 - 14:00. If I have the start time and end time whats the best way to find out if they ran over a single lunch time or in some cases several lunchtimes? Any suggestions as to how to code this or any tools in .net that would make this easier to do would be appreciated. Thanks

    M 1 Reply Last reply
    0
    • S Sam Heller

      I am currently trying to build some code which handles response times. I have a start time, an end time and a response time. Obviously enough the end time is the start time plus the response time. For example Start time 12:00 Response time 6 hours End time 18:00. My issue is finding out if the two times went over no working hours. Mainly lunchtime 13:00 - 14:00. If I have the start time and end time whats the best way to find out if they ran over a single lunch time or in some cases several lunchtimes? Any suggestions as to how to code this or any tools in .net that would make this easier to do would be appreciated. Thanks

      M Offline
      M Offline
      Mbire
      wrote on last edited by
      #2

      i think u should check to see if the timespan between the start time and the no work start time in question is positive, as in the start time is definitely before the no work start time. then if it is positive, check to see if the time span between the end time and the no work start time is also positive, depending on wat u subtracted from the other, then take it from there. if u dont understand this please say so and i can give u more structured pseudo code.

      S 1 Reply Last reply
      0
      • M Mbire

        i think u should check to see if the timespan between the start time and the no work start time in question is positive, as in the start time is definitely before the no work start time. then if it is positive, check to see if the time span between the end time and the no work start time is also positive, depending on wat u subtracted from the other, then take it from there. if u dont understand this please say so and i can give u more structured pseudo code.

        S Offline
        S Offline
        Sam Heller
        wrote on last edited by
        #3

        I think what you have mentioned here is pretty much what I have described but consider the following. If the start time was 09:00. And the response time was 8 hours, the time to respond by would be 17:00. The thing is this calculation would have gone over lunch time. At which point I need to add 1 additional hour as lunch time is not counted. DO you understand my problem here?

        M 1 Reply Last reply
        0
        • S Sam Heller

          I think what you have mentioned here is pretty much what I have described but consider the following. If the start time was 09:00. And the response time was 8 hours, the time to respond by would be 17:00. The thing is this calculation would have gone over lunch time. At which point I need to add 1 additional hour as lunch time is not counted. DO you understand my problem here?

          M Offline
          M Offline
          Mbire
          wrote on last edited by
          #4

          Hi Sam, My confusion is wat the input is and wat the output should be. Could you please clarify wat you are inputting into the system (whether its start or end time, duration or lunch start and end time), also clarify wat the output u want is and we can take it from there. Sheers

          S 1 Reply Last reply
          0
          • M Mbire

            Hi Sam, My confusion is wat the input is and wat the output should be. Could you please clarify wat you are inputting into the system (whether its start or end time, duration or lunch start and end time), also clarify wat the output u want is and we can take it from there. Sheers

            S Offline
            S Offline
            Sam Heller
            wrote on last edited by
            #5

            I have a start time, created when the job is logged. I have a response time, taken from the contract that covers the job. Therefore I have a 'time to respond to by'. Which is the logged time plus the given time span. Therefore this final time is what my calculations are aiming towards. My issue is how do I check if my two times have gone over a lunch time or not??

            M 1 Reply Last reply
            0
            • S Sam Heller

              I have a start time, created when the job is logged. I have a response time, taken from the contract that covers the job. Therefore I have a 'time to respond to by'. Which is the logged time plus the given time span. Therefore this final time is what my calculations are aiming towards. My issue is how do I check if my two times have gone over a lunch time or not??

              M Offline
              M Offline
              Mbire
              wrote on last edited by
              #6

              public function getTimeWorked(ByVal StartTime as date, ByVal Duration as TimeSpan, _
              ByVal EndTime as date, ByVal LunchStartTime as date, ByVal LunchDuration as TimeSpan) as TimeSpan

              dim ActualTimeWorked as TimeSpan
              dim TimeWorked as TimeDuration = StartTime - EndTime
              if (StartTime < LunchStartTime) and (EndTime > (LunchStartTime + LunchDuration)) then
              ActualTimeWorked = TimeWorked - LunchDuration
              endif
              return ActualTimeWorked
              end if

              Within the same if statement, u can modify the code to get if the guy finished work DURING lunch period and do the necessary calculations or if he started DURING the lunch period and calculate accordingly.

              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