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

function timeDiff

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

    function timeDiff

    I hope you can help me with a problem on a function which should work properly but isn�t.

    The function is:

    function timeDiff(time1, time2) {

    if(isNaN(Date.parse(time1)) || isNaN(Date.parse(time2))) return '';

    return ( ((Date.parse(time2) -Date.parse(time1))/1000)/60 )
    }

    The problem is that if I set time1 to say 25/05/11 and time2 to say 26/05/2011 the result should be 1440 (the number of minutes in I day) however the result I am receiving is 44640 (the number of minutes in 31 days)

    I have check the date formats on the server and the dbase and they are all set to the UK format of dd/mm/yyyy

    My data connection is SQL

    Any ideas ?

    Thanks
    Bobby123

    #2
    Re: function timeDiff

    Hi Forum

    My problem with this function is the date format, the function is calulating the result based on the mm/dd/yyyy US format and my date format is the UK format dd/mm/yyyy, but i have as yet been unable to fine a working javascript answer to this which doesn't retun error.

    Has anyone found a way to format the date to mm/dd/yyyy for the calulation part of the function which would deliver the correct result, then change the date format back to the dd/mm/yyyy.

    I have looked at a lot of javascript sites and forums over the past week or so and have yet to find a workable solution to this

    thanks
    bobby123

    Comment


      #3
      function timeDiff

      I am posting this question here as it is UK date related, I had posted it on the main forum and recieved no response or assistance. So I am now hoping someone in the UK will have come across the same issue and found a sulotion or can point me in the right direction.

      The function is:

      function timeDiff(time1, time2) {

      if(isNaN(Date.parse(time1)) || isNaN(Date.parse(time2))) return '';

      return ( ((Date.parse(time2) -Date.parse(time1))/1000)/60 )
      }

      The problem is that if I set time1 to say 25/05/11 and time2 to say 26/05/2011 the result should be 1440 (the number of minutes in I day) however the result I am receiving is 44640 (the number of minutes in 31 days)

      My problem with this function is the date format, the function is calulating the result based on the mm/dd/yyyy US format and my date format is the UK format dd/mm/yyyy, but i have as yet been unable to fine a working javascript answer to this which doesn't retun error.

      Has anyone found a way to format the date to mm/dd/yyyy for the calulation part of the function which would deliver the correct result, then change the date format back to the dd/mm/yyyy.

      I have looked at a lot of javascript sites and forums over the past week or so and have yet to find a workable solution to this

      My data connection is SQL

      Any ideas ?

      Thanks
      Bobby123

      Comment


        #4
        Re: function timeDiff

        I sometimes take a sledgehammer approach to these things... specially with dates since formats can drive you crazy. So, I figure out the format the input is, then change it to what I need in code. You only need to get minutes back so you don't really need to reformat a full date back out again. You're passing dates into your function but I'm just testing here directly on a grid... other than the dates coming in, the JS should be the same for you.

        Code:
        var newDate1 = {grid.Object}.getValue('G','APPTDATE',{Grid.RowNumber});
        var newDate2 = {grid.Object}.getValue('G','APPTDATE2',{Grid.RowNumber});
        
        var date1 = new Date(newDate1.slice(3,5) + '/' + newDate1.slice(0,2) + '/' + newDate1.slice(6,10));
        var date2 = new Date(newDate2.slice(3,5) + '/' + newDate2.slice(0,2) + '/' + newDate2.slice(6,10));
        
        var yr1 = date1.getFullYear();
        var mth1 = date1.getMonth();
        var day1 = date1.getDate();
        
        var yr2 = date2.getFullYear();
        var mth2 = date2.getMonth();
        var day2 = date2.getDate();
        
        var t1 = new Date(yr1, mth1, day1, 0, 0, 0, 0);
        var t2 = new Date(yr2, mth2, day2, 0, 0, 0, 0);
        var dif = t1.getTime() - t2.getTime();
        
        var Minutes_from_T1_to_T2 = dif / 1000 / 60;
        var Minutes_Between_Dates = Math.abs(Minutes_from_T1_to_T2);
        
        alert(Minutes_Between_Dates);

        Comment


          #5
          Re: function timeDiff

          Hi Bobby,

          I have done this with Xbasic Functions Declarations.

          After setting the variables, I get the value from the grid then Set the field value with the calculation. In my case all I wanted was the number of days. But for you to get the number of minutes multiply each day by 1440.
          Code:
          function calc_days as c (e as p)
           dim date1 as d
           dim date2 as d
           dim v_days as ndate1=e._currentRowDataNew.end_date
           date2=e._currentRowDataNew.start_date
           v_days=date1-date2
           
           e._set.days.value=v_days*1440
          end function
          Hope this gives you another point of view.
          Regards
          Keith Hubert
          Alpha Guild Member
          London.
          KHDB Management Systems
          Skype = keith.hubert


          For your day-to-day Needs, you Need an Alpha Database!

          Comment


            #6
            Re: function timeDiff

            Thanks Keith

            I will give it a go, and get back to you

            Thanks again
            Bobby123

            Comment


              #7
              Re: function timeDiff

              Thanks Davidk

              I will give it a try

              Thanks again

              Bobby123

              Comment

              Working...
              X