## DATEDIF function

DATEDIF calculates the difference between two dates and expresses the result in terms of months, days, or years.

The DATEDIF function, which isn’t documented in the Excel Help system, is one of the little Excel mysteries. Although the Excel 2000 Help system has an entry for DATEDIF, the function is not documented in earlier or later versions.

The syntax for the DATEDIF function is

`=DATEDIF(StartDate,EndDate,Interval)`

StartDate and EndDate are standard dates (or a reference to a cell that contains a date). The third argument, Interval, is a text string that specifies the unit of time that will be returned.

### Valid interval codes are described in this list:

• m:  The number of complete months between StartDate and EndDate.
• d:  The number of days between StartDate and EndDate.
• y:  The number of complete years between StartDate and EndDate.
• ym:  The number of months between StartDate and EndDate. This interval excludes years, so it works as though the two dates are in the same year.
• yd:  The number of days between StartDate and EndDate. This interval excludes years, so it works as though StartDate and EndDate are in the same year.
• md:  The number of days between StartDate and EndDate. This interval excludes both month and year, so it works as though StartDate and EndDate are in the same month and the same year.

This function is majorly used for Age calculation. To calculate the current Age, you can use the below formula:

=DATEDIF(DOB,TODAY(),”y”) & ” years, “&DATEDIF(DOB,TODAY(),”ym”) & “months, “&DATEDIF(DOB,TODAY(),”md”) & ” days”

Where DOB is the Date of Birth. You can use a cell reference or manually write your DOB. Ex: “17-Jul-81″

This formula returns a text string, like this: 33 years, 8 months, 17 days

## WEEKDAY Function

WEEKDAY Function tells you the day of week from a given date.

Syntax of Weekday formula: =WEEKDAY(Date)

Example 1: =WEEKDAY(“01-Apr-2014″) = 3 (3 for Tuesday)
Example 2: =WEEKDAY(TODAY()) = Current Day of week

WEEKDAY function returns the day number of a week as follows:

1 : Sunday
2 : Monday
3 : Tuesday
4 : Wednesday
5 : Thursday
6 : Friday
7 : Saturday

## Insert Random Dates in Excel

To insert a Random Date between 05-Jan-2014 and 30-Jun-2014, use the below formula. You can customize the formula as per your requirement.

`=RANDBETWEEN(DATE(2014,1,5),DATE(2014,6,30))`

Note: After you insert the formula you need to set the number format to Date, otherwise you’ll just see numbers.