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

  Add an interval to a date
 
  chubbard posted this script:
  This script takes a starting date, an interval specifying the measure of time to add, and the number of intervals to add. If you omit the starting date, today's date is used.

To specify an interval, pass in one of the following strings for the szInterval argument:

y (year)
mo (month)
d (date)
h (hour)
mi (minute)
s (second)
ms (millisecond)

webcall function dateAdd(szStart, szInterval, nNum)
{
    if(!szStart)
        szStart = Date();

    var dStart = new Date(szStart);
    var dReturn = dStart;
    nNum = Number(nNum);

    if(String.beginsWithIgnoreCase(szInterval,"y"))
        dReturn.setYear(dStart.getYear() + nNum);
    if(String.beginsWithIgnoreCase(szInterval,"mo"))
        dReturn.setMonth(dStart.getMonth() + nNum);
    if(String.beginsWithIgnoreCase(szInterval,"d"))
        dReturn.setDate(dStart.getDate() + nNum);
    if(String.beginsWithIgnoreCase(szInterval,"h"))
        dReturn.setHours(dStart.getHours() + nNum);
    if(String.beginsWithIgnoreCase(szInterval,"mi"))
        dReturn.setMinutes(dStart.getMinutes() + nNum);
    if(String.beginsWithIgnoreCase(szInterval,"s"))
        dReturn.setSeconds(dStart.getSeconds() + nNum);
    if(String.beginsWithIgnoreCase(szInterval,"ms"))
        dReturn.setMilliseconds(dStart.getMilliseconds() + nNum);

    return dReturn;
}
 
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