Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Weird time calculations - help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Weird time calculations - help

    I am trying to calculate the difference between two times to as part of a time tracking app.

    I have a UX with a startTime and and endTime field and want to calculate how much time has elapsed between the two. Should be very simple???

    In looking for help i found this video https://www.youtube.com/watch?v=28RhFiQSfo8 where Selwyn demonstrates just what I need but on a grid.

    I defined my own Javascript Function:
    function myTimeDiff(time1, time2) {

    if((isNaN(time1)) || (isNaN(time2))) return ' ';

    return (((time2-time1)/1000)/60);

    }

    I also customized my time picker so that the user has to use it and it provides the minutes in 15 minute intervals. Here's where it gets really strange. Below are the results for some different times (all are PM):

    1:00 to 1:15 = 21600 minutes
    1:00 to 1:30 = 43200 minutes

    The above are not correct but at least the interval is correct.

    If i change the end to 2:00 then my result is 44640 or just a bit more than the 30 minutes above...
    Changing the end to 2:15 I get 66240

    Any idea why I am getting these strange results? I thought it was supposed to return the difference in miliseconds...ux_test_15Min.jpg

    #2
    Re: Weird time calculations - help

    I am not sure how you set this up.
    normally you get the control data and convert that to date type and get the milliseconds and subtract from one another and convert to minutes.
    like if startime and endtime were to be time fields in a dialog/ux then
    the function would be
    Code:
    function myTimeDiff(time1, time2) {
    var t1 = new Date(time1);
    var t2 = new Date(time2);
    var t3 = (t2.getTime() - t1.getTime())/(1000*60);
    return t3;
    }
    t3 will have the difference in minutes.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    [email protected]
    Skype:[email protected]
    1 914 924 5171

    Comment


      #3
      Re: Weird time calculations - help

      Thanks -

      When I use your function i get the same results as I had with my earlier function...

      What puzzles me is the difference in the amount the "time" rises. The amount differs if I use the minutes and the hours in the time picker. I turned off the time picker and the results were the same. My startTime and my endTime fields on my UX are TIME format. Could that be the issue?

      At this point the UX is not bound to a table - also could that be an issue?

      Thanks

      Comment


        #4
        Re: Weird time calculations - help

        binding is not the issue,
        the time picker set up is.
        just set the time picker to custom and set the date as mm/dd/yyyy
        and the time to 0h:0m am
        and test if that is all okay then you can play with what ever you like.
        if you post your set up people can look at it and suggest correction if needed.
        thanks for reading

        gandhi

        version 11 3381 - 4096
        mysql backend
        http://www.alphawebprogramming.blogspot.com
        [email protected]
        Skype:[email protected]
        1 914 924 5171

        Comment


          #5
          Re: Weird time calculations - help

          I also customized my time picker so that the user has to use it and it provides the minutes in 15 minute intervals.
          show what you have done, may be that could help.
          thanks for reading

          gandhi

          version 11 3381 - 4096
          mysql backend
          http://www.alphawebprogramming.blogspot.com
          [email protected]
          Skype:[email protected]
          1 914 924 5171

          Comment


            #6
            Re: Weird time calculations - help

            I just looked at the video, same thing using date.parse method
            so your time picker is the problem.
            and you are not using date.parse in your function
            thanks for reading

            gandhi

            version 11 3381 - 4096
            mysql backend
            http://www.alphawebprogramming.blogspot.com
            [email protected]
            Skype:[email protected]
            1 914 924 5171

            Comment


              #7
              Re: Weird time calculations - help

              Thanks gandhi

              I replaced my function with yours, at first I was getting the same errors. Then I played with the field types, I tried all combinations of C, D and T fields in my UX. I have attached my current version. Here's where I am right now. If I restrict the date picker to default date only, it calculates properly showing 1440 minutes between two different days. As soon as I add a time function to the date/time picker it now shows "NaN" as the result.

              Appreciate any further insight you and others could provide.
              Attached Files

              Comment


                #8
                Re: Weird time calculations - help

                I won't be able to open it since it is created with version 12, I am at version 11, my end point.
                if you post your ux image and field type and time picker set up I can possibly see.
                thanks for reading

                gandhi

                version 11 3381 - 4096
                mysql backend
                http://www.alphawebprogramming.blogspot.com
                [email protected]
                Skype:[email protected]
                1 914 924 5171

                Comment


                  #9
                  Re: Weird time calculations - help

                  Here are some screen shots. I have included a shot of my main screen, the controls, the time picker and your Javascript code (thanks)

                  Hope this works...
                  Attached Files

                  Comment


                    #10
                    Re: Weird time calculations - help

                    it all looks good, the creation of date I think may need full year
                    you have two digits it could, I don't know for sure, cause problem
                    I can test later on in the evening.
                    nope that is not it
                    I tested it works with two digits too.
                    Last edited by GGandhi; 07-07-2016, 12:43 PM.
                    thanks for reading

                    gandhi

                    version 11 3381 - 4096
                    mysql backend
                    http://www.alphawebprogramming.blogspot.com
                    [email protected]
                    Skype:[email protected]
                    1 914 924 5171

                    Comment


                      #11
                      Re: Weird time calculations - help

                      I made a screencast,
                      this computer does not have a mic, so I showed everything I could.
                      there are two time fields, onChange event fires up to show the date and they are formatted MM/dd/yy 0h:0m am and the third control is numeric and the javascript is what I showed and it is used in the calculation.
                      it works as expected. please see.
                      if you want to do automatically then you could place the same javascript code in the on change event of the t2 and eliminate the calculation and it will do the same

                      http://screencast.com/t/9nee5C2M
                      thanks for reading

                      gandhi

                      version 11 3381 - 4096
                      mysql backend
                      http://www.alphawebprogramming.blogspot.com
                      [email protected]
                      Skype:[email protected]
                      1 914 924 5171

                      Comment


                        #12
                        Re: Weird time calculations - help

                        I am looking at the time picker format, did you set the timepicker customization where you can set the date and time format? (instead of using where you are using )
                        thanks for reading

                        gandhi

                        version 11 3381 - 4096
                        mysql backend
                        http://www.alphawebprogramming.blogspot.com
                        [email protected]
                        Skype:[email protected]
                        1 914 924 5171

                        Comment


                          #13
                          Re: Weird time calculations - help

                          Thanks so much for your help - still not working. I made a screen cast of my own, I tired to recreate the UX you did - it will still not calculate for the minutes...

                          I am wondering if there's some overall setting that's affecting my dates - I am operating on a Windows 97 machine. Not sure if that could have anything to do with it.
                          Attached Files

                          Comment


                            #14
                            Re: Weird time calculations - help

                            Even with the picker off and I manually input dates and times, the time still does not calculate. The minutes between calendar days will calculate but not the times.

                            Comment


                              #15
                              Re: Weird time calculations - help

                              I won't be able to look at the video till evening USA dst I will see why it doesnt
                              thanks for reading

                              gandhi

                              version 11 3381 - 4096
                              mysql backend
                              http://www.alphawebprogramming.blogspot.com
                              [email protected]
                              Skype:[email protected]
                              1 914 924 5171

                              Comment

                              Working...
                              X