vba to split duration in each hour and add record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #16
    We arrive at what I feel is a workable solution, or something relatively close, and you now wish to change your strategy. I really do not understand this logic.

    Comment

    • rajeevs
      New Member
      • Jun 2007
      • 171

      #17
      Dear ADezii
      Sorry, you misunderstood. I thought the demo revised 2 DB still incomplete and you are trying again with some options. That is why I suggested an alternate approach. If the revised2 is workable, I can start using it. Please let me know

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #18
        If the revised2 is workable, I can start using it.
        Only you will know if it is 'workable' or not.

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #19
          Attached is an example of how this would be done without VBA code. It only accounts for time ranges spanning 2 days. You would have to add more records to the time slots table to account for more days.
          Attached Files

          Comment

          • rajeevs
            New Member
            • Jun 2007
            • 171

            #20
            Dear ADezii
            Sorry for the delayed reply. I was busy with some personal travelling. The solution is workable but only one issue I am having. When it capture "Start" and Finish" for the logout in next date, that particular entry "00:00" 00:59 or any time in tha next date, the Date should show the logout date. Because "Start" and "Finish" time is in the next date. Hope my explanation is clear. Please help me to resolve that.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #21
              I am a little hazy on this aspect. Please provide some Sample Date showing what the Output should look like for day spans. Hopefully a visual display will clarify matters for me.

              Comment

              • rajeevs
                New Member
                • Jun 2007
                • 171

                #22
                Dear ADezii
                Thank you for the kind reply. I am attaching the same DB you have provided, but with manually adjusted expected results in the"PositionHrs " table. As you can see from the "MasterLogs " table, record 4 spans to 2 dates and in the expected results "PositionHr s" table the expected results are in record number 12 to 15. Hope that will give you a clear picture about what I am looking for. The login and logout fields doesnt need to be written to the "PositionHr s" table.
                Attached Files

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #23
                  I will have another look when I get a chance.

                  Comment

                  • ADezii
                    Recognized Expert Expert
                    • Apr 2006
                    • 8834

                    #24
                    Right now, I absolutely see no easy method to accomplish what you have requested since it would involve 2 different Methods of displaying the Data, one for Time Slots in a single Day, and another for spanning Multiple Days. What I have done is to essentially run the same block of Code twice, catching first the single Day Time Slots and then Multiple Day Time Slots. This will display the Records in PositionHrs first by Single Day, then by Multiple Day and will not reflect the natural order of Records in MasterLogs. This is not really desirable and neither is the duplication of Code, but it is all that I can come up with at this point in time. As soon as I get more time to look at it, I'll give it another try. In any event, take a look at the Revised Demo and see what you think.
                    Attached Files

                    Comment

                    • rajeevs
                      New Member
                      • Jun 2007
                      • 171

                      #25
                      Dear ADezii
                      Thank you for the effort and patience you have shown. Instead of repeating the code block, is there any way we can while adding the record which has next day logout to have the date captured from the logout. But not for the time period 2300-2359 - That should have date as login date.
                      Other wise the date will show previous date for hours in next date.

                      Comment

                      • ADezii
                        Recognized Expert Expert
                        • Apr 2006
                        • 8834

                        #26
                        Display only the Logout and not Login Date in PositionHrs?

                        Comment

                        • rajeevs
                          New Member
                          • Jun 2007
                          • 171

                          #27
                          Dear ADezii
                          The date is based on login and logout. for each hour in a login date the duration need to be found. and if the login and logout is different dates, then upto time 2359 the duration will fall into login date. any duration after 2359 of the login date will be recorded for the logout date. an example is if login 01-Aug-17 2350 and logout 02-Aug-17 0015, then there will be 2 entries need to be added to PositionHrs. 1 entry for 01-Aug-17 2300-2359 with a duration of 10 minutes and 2nd entry for 02-Aug-17 for time period 0000-0059 with a duration of 15 minutes. Hope my explanation is not confusing you. Please help

                          Comment

                          • ADezii
                            Recognized Expert Expert
                            • Apr 2006
                            • 8834

                            #28
                            Changed the overall Logic with no Code Duplication and added a Log Date Field which would indicate spanning a Day. I feel as though we are very close now.

                            P.S. - See entries for Babe Ruth and Barney Rubble.
                            Attached Files

                            Comment

                            • rajeevs
                              New Member
                              • Jun 2007
                              • 171

                              #29
                              Dear ADezii
                              Awesome. Even you mentioned that we are very close, but I feel that we have done. That is my first impression after a quick look. I will run with more records and let you know the out come. Thank you so much

                              Comment

                              • ADezii
                                Recognized Expert Expert
                                • Apr 2006
                                • 8834

                                #30
                                You are quite welcome, Good Luck with your Project!

                                Comment

                                Working...