**One that drifts under the radar a little is the WEEKDAY function**. This function will return a number that identifies the day of the week of a date.

This can be very useful. This blog post will look at two examples of what the WEEKDAY function can do for you.

Firstly, let’s look at how this function is written. The syntax of the function is;

=WEEKDAY(serial number, [return type])

The *serial number* is simply the date that you want to find out the weekday for.

The *return type* is a number from 1 to 7 that identifies the day of the week of the date. It provides a list so that you can choose how you would like the number returned e.g. Sunday = 1 to Saturday = 7, or Monday = 1 to Sunday = 7.

One situation where you may want to use the WEEKDAY function is to calculate a different rate of pay for weekend work.

In the list below the WEEKDAY function has been used with the IF function in column C to calculate a different rate of pay when working on a Saturday.

This was achieved my using the formula below in cell C2. This formula checks if the day of the week is equal to 7 (which indicates a Saturday). If this is true then the hours worked is multiplied by the Saturday rate, and if not then the hours worked is multiplied by the standard workday hourly rate.

=IF(WEEKDAY(A2,1)=7,B2*$F$3,B2*$F$2)

In this list the 04/02/2017 and the 11/02/2017 were a Saturday. You can see that Excel applied the increased rate of pay.

This example can be seen in action on my Excel timesheet for different rates for shift work post.

Let’s look at another example. Maybe we wish to highlight the dates in a list that fall on a Saturday or a Sunday.

- Select the range of dates you want to format.
- Click the
**Home**tab,**Conditional Formatting**button and then**New Rule**. - Select
**Use a formula to determine which cells to format**. - Enter a formula like the one below in the box provided.

=OR(WEEKDAY(A2,1)=1,WEEKDAY(A2,1)=7)

In this formula the OR function is used to test more than one condition. Although a range of dates was highlighted, we only reference cell A2 in the formula because it is the first cell of that range.

I used this function for this exact reason in my Excel Gantt Chart template.

Fortunately Excel has a full repertoire of fantastic date functions. Here are five of the best.

The TODAY function is used for a lot of good date calculation work. It returns the current date using your system clock. This is essential for so much of what you may be trying to do in Excel. As the date changes every day, this function is the technique for getting your Excel features or formulas to keep track of it so that they work every day.

It is written as below;

*=TODAY()*

No information is needed by this function as it gets what it needs from your computer.

The video below shows the TODAY function being used to highlight dates older than 30 days.

The NETWORKDAYS function is used to calculate the number of working days between two dates. It is written as;

*=NETWORKDAYS(Start Date, End Date, [Holidays])*

Holidays is optional and does not need to be supplied to the function. Holidays should be entered as a range of cells on your spreadsheet that contains the holidays.

For example, the NETWORKDAYS function can be used to calculate the number of working days between the date an order was taken and when it was dispatched.

*=NETWORKDAYS(B2,C2)*

The EDATE function returns the date a specified number of months before or after a start date. Its syntax is;

*=EDATE(Start Date, Months) *

For example, the EDATE function can be used to calculate the probation period of an employee. The formula below returns the end date of a 3 month probation period.

*=EDATE(C2, 3)*

The WORKDAY function returns a date a specified number of workdays before or after a start date. It is written as;

*=WORKDAY(Start Date, Days, [Holidays])*

For example, this function has been used in my Gantt Chart template. It calculates the finish date of a task given a start date (D7) and a tasks duration (C7). Holidays have been provided by using the nonworking range name.

*=WORKDAY(D7,C7,nonworking)*

Find out about the Excel Gantt chart template.

The DATEDIF function is used to calculate the difference between two dates. The difference can be returned as years, months or days.

This function is not documented in Excel (weirdly?) so when entering it into a cell you will not get any information. However its syntax is;

*=DATEDIF(Start Date, End Date, Interval)*

The interval should be entered as a string so using double inverted commas. Use the first letter of the interval you wish to return e.g. “y” for years or “m” for months.

The interval can also be entered as a combination. So for example “ym” would calculate the number of months between the two dates excluding years. This returns a result as if the dates were in the same year.

The DATEDIF function could be used to calculate a person’s age. For example, the formula below will calculate the age of a person as of the current date, where cell B2 contains the person’s date of birth.

*=DATEDIF(B2,TODAY(),”y”)*

If you wanted to return the persons age as how many years and months old they are we could use the formula below.

*=DATEDIF(B2,TODAY(),”y”)&” years “&DATEDIF(B2,TODAY(),”ym”)&” months”*

This formula uses the ampersand to concatenate two DATEDIF functions and some text.

Learning Excel is easy with Computergaga – browse our website to find out more

]]>