DateBetween
Date/Time function.
The DateBetween function returns the number of specified time intervals between two dates.
Usage
It can return the number of days between two dates, the number of weeks between today and the end of the year, ...
Syntax
val=DateBetween(<interval$>,<date1$>,<date2$>)
Parameters
<interval$>, string specifying the time interval you want to use as the unit of difference between <date1$> and <date2$>.
<interval$> value
Unit of time difference
d
Day
w
Weekday
ww
Week (number of weeks), same as w
y
Day of the year, same as d
yyyy
Year (number of years)
q
Quarter (number of quarters)
m
Month (number of months)
h
Hours (number of hours)
n
Minutes (number of minutes)
s
Seconds (number of seconds)
<date1$>, string, first date value to use in the calculation. The date format must be the one as in Regional settings (05/01/2007 for 1st of May in US format, 01/05/2007 in European format).
<date2$>, string, second date value to use in the calculation
Return value
Returns the number of time intervals as an integer. If one of the parameter is incorrect (invalid date for example) and if #IgnoreErrors=1, the function returns 0. A negative number is returned if <date2$> is before <date1$>.
Remarks
If the year is not included in <date$>, the current year is added automatically.
If <interval$> is "w" and <date1$> is a Monday, the function returns the number of Mondays between <date1$> and <date2$> without taking the first Monday <date1$> (see second example).
Examples
val=DateBetween( "d","12/01/2007","12/31/2007") 'returns 30
val=DateBetween( "w","12/24/2007","12/30/2007") 'returns 0 as 24 December 2007 is a Monday
ret=DateBetween("s","01/12/2007 07:05:00","01/12/2007 08:05:10") 'returns 70 for 70 secs between 7:05 and 8:05:10