DateDiff Function

Returns the number of time intervals between two dates.

DateDiff ( interval, date1, date2 )

Parameters

Interval  -  (Input, expression, Required)

Specifies the interval to add. It should be one of the following predefined constants:

date1  -  (Input, expression, Required)

Starting date/time. If date1 is specified as a string expression, Newlook will convert it to a date/time as long as it contains a date and/or time in the form “mmm d, yyyy” and/or “hh:nn:ss” (e.g. “Feb 1, 1999 10:30:00”).

date2 - (Input, expression, Required) 

Ending date/time. If date2 is specified as a string expression, Newlook will convert it to a date/time as long as it contains a date and/or time in the form “mmm d, yyyy” and/or “hh:nn:ss” (e.g. “Feb 1, 1999 10:30:00”).

Return Value

Difference between date1 and date2. If date2 is earlier than date1, a negative value is returned. Error is returned if either date is invalid.

Examples

DateDiff (IntYears, Now(), "1 Jan 2000”)

No. of years since the millennium

DateDiff (IntQuarters, Now(), “1 Jan 2000”)

No. of quarters since the millennium

DateDiff (IntMonths, Now (), “1 Jan 2000”)

No. of months since the millennium

DateDiff (IntWeeks, Now (), “1 Jan 2000”)

No. of weeks since the millennium

DateDiff (IntDays, Now (), “1 Jan 2000”)

No. of days since the millennium

DateDiff (IntHours, Now (), “1 Jan 2000 00:00:00”)

No. of hours since the millennium

DateDiff (IntMinutes, Now (), “1 Jan 2000 00:00:00”)

No. of minutes since the millennium

DateDiff (IntSeconds, Now(), “1 Jan 2000 00:00:00”)

No. of seconds since the millennium

TIP:

Functions are specifically for use in the Macro Editor. Refer to Microsoft's official VB and JScript documentation for scripting equivalents.

See Also

Date function | DateAdd function | DateDiff function | Day function | Hour function | Minute function | Month function | Now function | Second function | Time function | Week function | WeekDay function | Year function


© 2004-2021 looksoftware. All rights reserved.