18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Working with Dates and Times 13<br />

Determining the day of the year<br />

January 1 is the first day of the year, and December 31 is the last day. But what about all those days in<br />

between? The following formula returns the day of the year for a date stored in cell A1:<br />

=A1-DATE(YEAR(A1),1,0)<br />

The following formula returns the number of days remaining in the year after a particular date (assumed to<br />

be in cell A1):<br />

=DATE(YEAR(A1),12,31)-A1<br />

When you enter either of these formulas, Excel applies date formatting to the cell. You need to apply a nondate<br />

number format to view the result as a number.<br />

To convert a particular day of the year (for example, the 90th day of the year) to an actual date in a specified<br />

year, use the formula that follows. This formula assumes that the year is stored in cell A1 and the day of the<br />

year is stored in cell B1.<br />

=DATE(A1,1,B1)<br />

Determining the day of the week<br />

The WEEKDAY function accepts a date argument and returns an integer between 1 and 7 that corresponds to<br />

the day of the week. The following formula, for example, returns 3 because the first day of the year 2008<br />

falls on a Tuesday:<br />

=WEEKDAY(DATE(2008,1,1))<br />

The WEEKDAY function uses an optional second argument that specifies the day numbering system for the<br />

result. If you specify 2 as the second argument, the function returns 1 for Monday, 2 for Tuesday, and so on.<br />

If you specify 3 as the second argument, the function returns 0 for Monday, 1 for Tuesday, and so on.<br />

TIP<br />

You can also determine the day of the week for a cell that contains a date by applying a custom<br />

number format. A cell that uses the following custom number format displays the day of<br />

the week, spelled out:<br />

dddd<br />

Determining the date of the most recent Sunday<br />

You can use the following formula to return the date for the previous Sunday. If the current day is a Sunday,<br />

the formula returns the current date:<br />

=TODAY()-MOD(TODAY()-1,7)<br />

To modify this formula to find the date of a day other than Sunday, change the 1 to a different number<br />

between 2 (for Monday) and 7 (for Saturday).<br />

Determining the first day of the week after a date<br />

This next formula returns the specified day of the week that occurs after a particular date. For example, use<br />

this formula to determine the date of the first Monday after June 1, 2007. The formula assumes that cell A1<br />

contains a date and cell A2 contains a number between 1 and 7 (1 for Sunday, 2 for Monday, and so on).<br />

=A1+A2-WEEKDAY(A1)+(A2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!