Search these areas:
Help
Support Forums
Product Info



-Introduction
-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Views
-Templates
-Components
-Data Analysis
-Members
-Security
-Importing
-Exporting
-FTP
-JavaScript
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-Glossary
-New Responsive UI Module





DataWeb Help
Support Forums
Tutorial
Script Library
Knowledge Base

Home > Support

Script Library

  Find elapsed time in years, days, hours, minutes, or seconds
 
  chubbard posted this script:
  This function calculates elapsed time in a specified unit of time -- years, days, hours, minutes, or seconds.

To call this function, pass in a starting date and an ending date, and a string specifying one of the following intervals:

y (year)
d (day)
h (hour)
m (minute)
s (second)

webcall function calcElapsedTimeInterval(dStart, dEnd, szInterval)
{
    dStart = new Date(dStart);
    dEnd = new Date(dEnd);

    var nMs = dEnd - dStart;

    if(String.beginsWithIgnoreCase(szInterval, "y"))
        return Math.floor(nMs/(1000 * 60 * 60 * 24 * 365)) + " years";
    if(String.beginsWithIgnoreCase(szInterval, "d"))
        return Math.floor(nMs/(1000 * 60 * 60 * 24)) + " days";
    if(String.beginsWithIgnoreCase(szInterval, "h"))
        return Math.floor(nMs/(1000 * 60 * 60)) + " hours";
    if(String.beginsWithIgnoreCase(szInterval, "m"))
        return Math.floor(nMs/(1000 * 60)) + " minutes";
    if(String.beginsWithIgnoreCase(szInterval, "s"))
        return Math.floor(nMs/(1000)) + " seconds";
}
 
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us