Add time in access using 2 fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3655

    #16
    Have you tried stripping the query of all extraneous tables, forms and what-nots? Then try recreating what I demonstrated above. See if it is something related to the complexity first. If it works, then we redirect our efforts toward decomplexifying things......

    Comment

    • DJRhino1175
      New Member
      • Aug 2017
      • 221

      #17
      Here is a screen shot of my query.
      Attached Files

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3655

        #18
        Impossible to see it that small. I can only presume it is similar to the one I provided. Can you post a list of returned values from your query? I'll se if that has anything to do with it.

        Comment

        • DJRhino1175
          New Member
          • Aug 2017
          • 221

          #19
          Ok I just made a query based off of the query I sent as a screenshot and the formula works perfectly, except I don't need it in seconds, but that should be just changing the format.

          Comment

          • twinnyfo
            Recognized Expert Moderator Specialist
            • Nov 2011
            • 3655

            #20
            So....... I guess it worked? I must be sharing some of my gremlins over the internet!

            Comment

            • DJRhino1175
              New Member
              • Aug 2017
              • 221

              #21
              Yeah its weird that I just needed to make a query of a query to get it to work. So now if I switch my forms record source to this new query I'm hoping everything will still work.

              Comment

              • DJRhino1175
                New Member
                • Aug 2017
                • 221

                #22
                ok, son now I get a #error on this field if some of the data is missing, I'm assuming I need a Nz() the there somewhere. Would I put this in the front of the formula?

                Comment

                • twinnyfo
                  Recognized Expert Moderator Specialist
                  • Nov 2011
                  • 3655

                  #23
                  It could also be a divide by zero error. Math functions do not like to calculate null values, so an Nz([Value], 0) should alleviate those problems, outside of div/0 errors.

                  Comment

                  • DJRhino1175
                    New Member
                    • Aug 2017
                    • 221

                    #24
                    Code:
                    EndTimeOfProduction: DateAdd("n",[ProductionTime],[StartTimeOfProduction])
                    Where exactly would I put Nz(Value], o

                    Comment

                    • DJRhino1175
                      New Member
                      • Aug 2017
                      • 221

                      #25
                      Sorry I figured it out after I scratched my head and tried a few things. The only thing is I cannot get the seconds to disappear. I have the format set for medium time and its showing, for example 00:00:00 am

                      Comment

                      • DJRhino1175
                        New Member
                        • Aug 2017
                        • 221

                        #26
                        I also noticed that when it goes past midnight that it adds a date in front of it, is there away to make this not show?

                        Comment

                        • twinnyfo
                          Recognized Expert Moderator Specialist
                          • Nov 2011
                          • 3655

                          #27
                          Simple:

                          Code:
                          EndTimeOfProduction: Format(DateAdd("n",[ProductionTime],[StartTimeOfProduction]),"Medium Time")

                          Comment

                          • DJRhino1175
                            New Member
                            • Aug 2017
                            • 221

                            #28
                            Perfect. Thank you so much. This is what the final Code ended up looking like.

                            Code:
                            EndTimeOfProduction: Format(Nz(DateAdd("n",Nz([ProductionTime]),[StartTimeOfProduction])),"Medium Time")

                            Comment

                            • twinnyfo
                              Recognized Expert Moderator Specialist
                              • Nov 2011
                              • 3655

                              #29
                              Glad I could hepp. Sorry it took so long to resolve this issue.

                              Comment

                              Working...