Home : Products : Hach WIMS : Hach WIMS Client : Documentation : Function Reference : Spread Functions : Date Functions : DATEDIFF
Q10696 - INFO: DATEDIFF

DATEDIFF returns the number of time intervals between two specified dates.

SYNTAX:

DATEDIFF(Interval,Date1,Date2)

Interval: The interval of time you use to calculate the difference between date1 and date2.  The following table displays the valid Intervals.

  Interval    Description 
"yyyy" Year
"y" Day of Year
"q" Quarter
"m"  Month
"d" Day
"w" Weekday
"ww" Week
"h" Hour
"n" Minute
"s" Second

date1: A string representing a valid date, i.e. "1/2/2004", a cell reference to a cell containing a string, or a function that returns a date string (such as DSORT)

date2: A string representing a valid date, i.e. "1/2/2004", a cell reference to a cell containing a string, or a function that returns a date string (such as DSORT)

NOTES:

You can use the DateDiff function to determine how many specified time intervals exist between two dates. For example, you might use DateDiff to calculate the number of days between two dates, or the number of weeks between today and the end of the year.

To calculate the number of days between date1 and date2, you can use either Day of year ("y") or Day ("d"). When interval is Weekday ("w"), DateDiff returns the number of weeks between the two dates. If date1 falls on a Monday, DateDiff counts the number of Mondays until date2. It counts date2 but not date1. If interval is Week ("ww"), however, the DateDiff function returns the number of calendar weeks between the two dates. It counts the number of Sundays between date1 and date2. DateDiff counts date2 if it falls on a Sunday; but it doesn't count date1, even if it does fall on a Sunday.

If date1 refers to a later point in time than date2, the  DateDiff function returns a negative number.

EXAMPLES:

DateDiff("M","1/31/2004","2/2/2004") - Returns 1.

DateDiff("D",A1,A2) - Returns 30. Cell A1 = 1/1/2004, A2 = 1/31/2004

DATEDIFF("D",DATE(1,"mm/dd/yy",1),DATE(-1,”mm/dd/yy”,-1))+1 - Returns the number of days in the report.

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 2/3/2008 7:11 AM.
Last Modified on 9/25/2008 11:30 AM.
Last Modified by No Author Name Available!.
Article has been viewed 2628 times.
Rated 0 out of 10 based on 0 votes.
Print Article
Email Article