(Reading time: 1 minute)

Excel

In Excel, the DateDiff function returns the difference between two date values, based on the interval specified.

The syntax for the DateDiff function is:

DateDiff( interval, date1, date2, [firstdayofweek], [firstweekofyear] )

interval is the interval of time to use to calculate the difference between date1 and date2. Below is a list of valid interval values.

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of year
  • d - Day
  • w - Weekday
  • ww - Week
  • h - Hour
  • n - Minute
  • s - Second

date1 and date2 are the two dates to calculate the difference between.

firstdayofweek is optional. It is a constant that specifies the first day of the week. If this parameter is omitted, Excel assumes that Sunday is the first day of the week.

firstweekofyear is optional. It is a constant that specifies the first week of the year. If this parameter is omitted, Excel assumes that the week containing Jan 1st is the first week of the year.


Example

 
 
 
Sub TestDates 
 
 
     mydiff = DateDiff("d", "8/14/09", "8/14/10")
 
 
End Function
 
 
 

Oxygen
Author: Oxygen
Other articles by this author

Chillzee Tag Cloud

Let's Socialize

About Chillzee

Chillzee.com is an entrepreneurship portal.

The site provides informative topics on Organizational and Strategic needs.