scripting@wanadoo.nl




DateMath()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
25 March 2002 DateMath()
AuthorScriptLogic Corporation
Action Performs mathematical computations on a date or computers days between two dates.
SyntaxDateMath ("date1", "date2")
-or-
DateMath ("date1", integer) 
Parameters
  • date1 (Required / String) A date in the form of "YYYY/MM/DD"
  • date2 -or- integer (Required / String) A date in the form of "YYYY/MM/DD" or an integer (positive or negative) 
  • RemarksDate parameters must be in the form of YYYY/MM/DD. 
    ReturnsIf two dates are passed, the number of days between them is returned as in integer.
    If a date is passed as "date1" and a number of days is passed as integer, the resulting date will be returned in the form of YYYY/MM/DD. 
    DependenciesSerialDate() 
    Examples
    $DaysBetween=Datemath("2001/04/01","1999/01/01")
    
    $LastWeek=DateMath(@Date,-7)
    
     
    Source
    FUNCTION DateMath ($expd1, $expd2)
      ; Author: ScriptLogic Corporation
      ; if both parameters are dates (yyyy/mm/dd), a positive integer indicating
      ; the days between the two dates will be returned.
      ; if the first is a date (yyyy/mm/dd) and the second is an integer
      ; (number of days), a new date will be returned.
      ;
      ; UDF dependencies: SerialDate, Abs
    
      SELECT
      CASE InStr($expd1,'/') AND InStr($expd2,'/')
        ; two date passed - return daysbetween integer
        $datemath=serialdate($expd1)-serialdate($expd2)
        IF ($datemath < 0)
          $datemath=$datemath*-1
        ENDIF
      CASE InStr($expd1,'/') AND 1-InStr($expd2,'/')
        ; date and a number passed - return date
        $expd2=0+$expd2
        $datemath=serialdate(serialdate($expd1)+$expd2)
      CASE 1
        ; incorrect parameters passed
      ENDSELECT
    ENDFUNCTION ; - DateMath -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter