Skip to content

YEAR, MONTH, DAY

You are currently viewing a sample of the Cram Kit. Click here to unlock everything.

These Excel formulas are pretty self explanatory, but for the sake of explaining it with a real-world example, check out the below calendar.

What if I were to ask you the year of the circled day? You would answer "2018".

The YEAR function returns the year for a given timestamp.

What's the circled day's month? It's in "November", or the "11th" month of the year.

The MONTH function returns the month for a given timestamp.

And lastly, what's the day for the circled date? It's the "15th" day of the month.

The DAY function returns the day in number form for a given timestamp.

Coding with YEAR, MONTH, & DAY

Let's see how this works with the same date above, but in an Excel worksheet.

Because in Excel, specific moments in time are saved as "serial_numbers", not dates. The number depicts the number of days from January 1, 1900.

For example, January 3, 1900 would have a serial_number of 3, because it's 3 days after January 1, 1900.

It's through the DATE, YEAR, MONTH, and DAY functions that we can convert these serial_numbers into understandable parts of time.

YEAR coded

Here is the template for the YEAR function:

=YEAR(serial_number)

To determine the year of the given date, we'd code the following...

=YEAR(B1)

...which would result in:

MONTH coded

The template for MONTH is:

=MONTH(serial_number)

So, for our month, we'd type the following:

=MONTH(B1)

This would result in...

DAY coded

Lastly, here's the template for DAY:

=DAY(serial_number)

To determine the day of the month for the timestamp, we'd code this:

=DAY(B1)

This code turns into the following output:

Based on this result, we are able to understand that 43419 represents 11/15/2018.

Activate AutoScroll