Time Functions in Excel: How to Work with Dates

00Comment iconComment iconComment iconComment icon

Discover Excel's essential tools for dealing with dates, learn how to use time functions in an effective and simplified way, and master the art of controlling calendars and deadlines.

Writer image

번역자Editorial

Writer image

개정자Editorial

Edit Article

In this lesson, we will explore the Excel functions that deal with time and dates. These functions are essential for working with deadlines, day calculations, hours, minutes, and much more. We will cover functions such as TODAY, NOW, DAYS, DATE, HOUR, MINUTE, SECOND, and others. Each function will be explained with practical examples to make understanding easier.

The TODAY function

The TODAY function returns the current date. It is useful for creating spreadsheets that always show the current date without needing manual updates.

Syntax:

=TODAY()

Example:

If today is 10/10/2023, the formula =TODAY() will return 10/10/2023.

The NOW function

The NOW function returns the current date and time. It is useful for recording the exact moment when an action was performed.

Syntax:

=NOW()

Example:

If today is 10/10/2023 and the time is 14:30, the formula =NOW() will return 10/10/2023 14:30.

The DATE function

The DATE function creates a date from year, month, and day values.

Syntax:

=DATE(year; month; day)

Example:

If you have the year in A1 (2023), the month in B1 (10), and the day in C1 (15), the formula =DATE(A1; B1; C1) will return 15/10/2023.

The HOUR function

The HOUR function extracts the hour from a time value.

Syntax:

=HOUR(time_value)

Example:

If you have the value 14:30:45 in cell A1, the formula =HOUR(A1) will return 14.

The MINUTE function

The MINUTE function extracts the minutes from a time value.

Syntax:

=MINUTE(time_value)

Example:

If you have the value 14:30:45 in cell A1, the formula =MINUTE(A1) will return 30.

The SECOND function

The SECOND function extracts the seconds from a time value.

Syntax:

=SECOND(time_value)

Example:

If you have the value 14:30:45 in cell A1, the formula =SECOND(A1) will return 45.

The DAY function

The DAY function extracts the day from a date.

Syntax:

=DAY(date)

Example:

If you have the date 15/10/2023 in cell A1, the formula =DAY(A1) will return 15.

The MONTH function

The MONTH function extracts the month from a date.

Syntax:

=MONTH(date)

Example:

If you have the date 15/10/2023 in cell A1, the formula =MONTH(A1) will return 10.

The YEAR function

The YEAR function extracts the year from a date.

Syntax:

=YEAR(date)

Example:

If you have the date 15/10/2023 in cell A1, the formula =YEAR(A1) will return 2023.

The WEEKDAY function

The WEEKDAY function returns the day of the week corresponding to a date, where 1 = Sunday and 7 = Saturday.

Syntax:

=WEEKDAY(date; [return_type])

Example:

If you have the date 15/10/2023 in cell A1, the formula =WEEKDAY(A1; 1) will return 1 (Sunday).

The DAYS or DATEDIF function

The DAYS function calculates the number of days between two dates.

Syntax:

=DAYS(end_date; start_date)

Example:

If you have the start date in A1 (01/01/2023) and the end date in B1 (10/10/2023), the formula =DAYS(B1; A1) will return 282.

In Google Sheets, you will have to use DATEDIF:

=DATEDIF(start_date; end_date; unit)

For example, if you have the start date in A1 (01/01/2023) and the end date in B1 (10/10/2023) and want to know how many days there are between them, you will do the following:

=DATEDIF("01/01/2023"; "10/10/2023"; "D")

The NETWORKDAYS function

The NETWORKDAYS function calculates the number of business days between two dates, excluding weekends and holidays.

Syntax:

=NETWORKDAYS(start_date; end_date; [holidays])

Example:

If you have the start date in A1 (01/10/2023) and the end date in B1 (15/10/2023), the formula =NETWORKDAYS(A1; B1) will return 11 business days (considering only Saturdays and Sundays as non-working days).

The EDATE function

The EDATE function returns a date that is a specific number of months before or after a start date.

Syntax:

=EDATE(start_date; months)

start_date: The reference date.

months: The number of months you want to add (positive) or subtract (negative) from the start date.

Suppose you have the date 15/10/2023 in cell A1 and want to add 3 months to that date. =EDATE(A1; 3) would result in 15/01/2024

Practical exercises on time and date functions

1. Determine the day of the week for the date 15/10/2023 in cell A1, where 1 = Sunday and 7 = Saturday.

2. Calculate the number of business days between 01/10/2023 (cell A1) and 15/10/2023 (cell B1), considering only Saturdays and Sundays as non-working days.

3. Given the table below, calculate the number of business days between the start and end dates, excluding the listed holidays.

StartEndHolidays
01/10/202315/10/202312/10/2023
01/11/202315/11/202302/11/2023
01/12/202315/12/202325/12/2023

4. Given the table below, calculate the age of each person based on their date of birth and the current date (use the TODAY function).

NameDate of Birth
João15/10/1990
Maria20/05/1985
Pedro01/12/2000

5. Given the table below, calculate the expiration date of each contract by adding 12 months to the start date.

ContractStart Date
Contract 115/10/2023
Contract 220/05/2023
Contract 301/12/2023

6. Given the table below, calculate the total hours worked by each employee, considering clock-in and clock-out times.

NameClock-inClock-out
João08:0017:00
Maria09:0018:30
Pedro07:3016:45

7. Given the table below, calculate each employee’s lateness, considering that the clock-in time should be 08:00.

NameClock-in
João08:15
Maria07:45
Pedro08:30

8. Given the table below, calculate each person's age in years, months, and days based on their date of birth and the current date.

NameDate of Birth
João15/10/1990
Maria20/05/1985
Pedro01/12/2000

9. Given the table below, calculate how many days are left until each person’s next birthday.

NameDate of Birth
João15/10/1990
Maria20/05/1985
Pedro01/12/2000