In this tutorial, I will show you the most important date functions of Google Sheets. Date functions are extremely useful for working with time data, analyzing it, or formatting it in a specific way. Whether you need the current date, calculate data, or simply adjust formats, the following steps will help you use Google Sheets optimally for your needs.
Main Insights
In this tutorial, you will learn the basic date functions, including:
- TODAY: Get the current date
- YEAR, MONTH, DAY: Extract components of a date
- DATE: Create a date from year, month, and day
- NOW: Display the current date with time
- WEEKDAY: Determine the weekday from a date
- DATEDIF: Calculate the difference between two dates
Step-by-Step Guide
Using the TODAY Function
Let's start with the first and simplest date function: the TODAY function. This function returns the current date. Simply write the following formula into a cell:
=TODAY()
This will instantly show you the date without manually entering anything.
Adjusting Date Format
The formatting of a date can vary depending on the need. To adjust the date format, follow these steps:
- Select the cell or range where the date is located.
- Click on "Format" in the menu.
- Then choose "Number" and then "Date".
Here, you can choose from different date formats and even create custom formats.
Make sure that the spreadsheet settings match your language and time zone, as this can affect the display of the date.
Utilizing Time Services for Days and Months
You can further use the current date input to create a list of consecutive days. For example, if you start with a date of February 25, 2021, you simply drag the small box in the lower right corner of the cell down to generate the next dates.
To extract the month or year of a specific date, you use the YEAR and MONTH functions. Simply enter the dates in separate cells and drag the formulas down to get the results for multiple rows.
For example
=YEAR(A1)
or
=MONTH(A1)
This will give you the year or month of the date specified in A1.
Using the DAY Function
A similar function is the DAY function, which returns the day of a date. Simply enter a date and drag your formula down again to get the corresponding days.
Working with the DATE Function
Sometimes you need to create a date from specific entries like year, month, and day. In this case, you use the DATE function:
=DATE(YEAR, MONTH, DAY)
For example
=DATE(2021, 2, 25)
to generate the date. Remember to drag the formula down accordingly to get similar entries.
Get the current date and time with NOW
The NOW function shows you the current date and time, which is especially useful when you need timestamps. Use the following formula:
=NOW()
The result will dynamically update interestingly when you reload or refresh the table.
Weekday and Week Number
You can also determine the weekday of a specific date by using the WEEKDAY function. Enter the date again and drag the formula down:
=WEEKDAY(Date)
This function returns the number of the weekday, so Sunday has the value of 1 and Saturday has the value of 7.
To get the week number, you can use the similar function WEEKNUM.
DATEDIF for Date Differences
One of the most versatile functions is the DATEDIF function, which allows you to calculate the difference between two dates. The syntax is as follows:
=DATEDIF(Start date, End date, "Unit")
You provide the start date and end date in quotation marks and choose the unit (e.g., "d" for days, "m" for months, or "y" for years).
For example:
=DATEDIF("2021-02-23", "2021-03-25", "d")
This gives you the number of days between these two dates.
Summary
In this tutorial, you learned how to effectively use basic date functions in Google Sheets. You can get the current date, analyze and differentiate data. The ability to display data in various formats and automatically update it is great for any type of project.
Frequently Asked Questions
How can I display the current date in Google Sheets?Use the function =TODAY() to display the current date.
What does the DATEDIF function do?The function calculates the difference between two dates and returns the number of days, months, or years.
Can I customize the date format?Yes, you can set the date format in the formatting option of Google Sheets.
How do I drag a list of dates in Google Sheets?Enter a date, click on the small square in the bottom right corner of the cell, and drag it down.
Which function returns the current time?Use the function =NOW() to display the current date and time.