Excel’s DATE() function is a typical example of a function that you will probably only ever use in conjunction with other functions to create a solution to a problem. Date (and time) values are particularly tricky values to work with as they are non-decimal; remember when your primary school teacher told you that you can’t add apples and oranges?

While the DATE function builds up a date, the DAY, MONTH and YEAR functions break a date apart.

In this post:
  1. Syntax
  2. Example
  3. Next steps
Required knowledge:

1. Syntax

=DATE(year,month,day)

2. Example

In the example below, both cells A2 & B2 contain date values. To work out if the dates are the same except for the year, we need to separate the dates into their year, month and day components. Once we have the day part of the 2 dates, we can compare them to see if they are the same; once we have the month part of the 2 dates, we can do the same. We ignore the year parts as in this example we are trying to work out if it is someone’s birthday.

An example of Excel's TODAY() function.An example of Excel's TODAY() function in action.

=IF(AND(MONTH(A2) = MONTH(B2), DAY(A2) = DAY(B2)), "HAPPY BIRTHDAY!", "Sorry, it's not your day.")

3. Next steps

Use Excel’s TODAY() function to make the above solution dynamic!


References:

  1. Microsoft (no date) DATE function | Microsoft Support. Microsoft. Available at: https://support.microsoft.com/en-us/office/date-function-e36c0c8c-4104-49da-ab83-82328b832349. (Accessed: February 20, 2023).

By MisterFoxOnline

Mister Fox AKA @MisterFoxOnline is an ICT, IT and CAT Teacher who has just finished training as a Young Engineers instructor. He has a passion for technology and loves to find solutions to problems using the skills he has learned in the course of his IT career.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.