Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Working with Dates and Time | Basic Functions
Google Spreadsheets
course content

Conteúdo do Curso

Google Spreadsheets

Google Spreadsheets

1. Introduction to Google Sheets
2. Formatting of Cells and Ranges
3. Advanced Formatting of Cells
4. Sorting, Filtering and Cleaning Data
5. Creating Charts
6. Basic Functions
7. Logical Functions
8. Collaboration and Security

book
Working with Dates and Time

The TODAY function returns the current date in date format without the time. This is useful for automatically updating the date in calculations when the document is recalculated.

The NOW function returns the current date and time. This is useful for automatically tracking the exact time of updates or other operations.

Syntax and Examples

TODAY()
NOW()

FormulaResultComment
TODAY()9/30/2024The TODAY function returns the current date without time. The result will automatically update each day.
NOW()9/30/2024 14:31:17The NOW function returns the current date and time. The value updates whenever the table is modified or opened.
TODAY() + 710/7/2024When adding a number to TODAY, it is interpreted as the number of days. In this example, it returns the date 7 days from now.
TEXT(NOW(), "HH:MM")14:31TEXT formats the NOW result to display only the time in HH:MM format. This is useful when working with time only.
TEXT(TODAY(), "dddd")MondayTEXT formats the date into the full weekday name. In this case, it returns "Monday."
IF(TODAY() = DATE(2024, 10, 1), "Today", "Not today")Not todayThe condition checks if today's date matches the specified date (October 1, 2024). If it matches, it returns "Today," otherwise "Not today."

Working with Dates

The DATE function allows you to create a date from individual year, month, and day values. This is useful for combining values into a single date or for date calculations.

The DATEVALUE function converts a text string representing a date into a date format. This is useful when the date is written as a string, and you need to work with it as a numerical value for calculations.

Syntax and Examples

DATE(year, month, day)

  • year - The year component of the date.
  • month - The month component of the date;
  • day - The day component of the date;

DATEVALUE(date_string)

  • date_string - The string representing the date;
    • Understood formats include any date format that is automatically converted when entered into a cell, without quotation marks. The formats may vary based on region and language settings.
FormulaResultComment
DATE(2024, 12, 31)12/31/2024Creates the date December 31, 2024, by combining the year, month, and day.
DATE(2024.8, 2.7, 10)2/10/2024Fractional values are rounded to integers, creating the date February 10, 2024.
DATE(2025, 1, 1) - DATE(2024, 1, 1)366The difference in days between January 1, 2024, and January 1, 2025, including the leap year.
DATEVALUE("12/31/2024")12/31/2024Converts the text string "12/31/2024" into the date December 31, 2024.
DATEVALUE("January 1, 2025")1/1/2025Converts the text "January 1, 2025" into the date January 1, 2025.
DATEVALUE("2024-12-29")12/29/2024Converts the string "2024-12-29" into the date December 29, 2024.
DATEVALUE("25-Dec-2024")12/25/2024Converts the text "25-Dec-2024" into the date December 25, 2024.
IF(DATEVALUE("12/15/2024") < TODAY(), "Past", "Future")FutureChecks whether December 15, 2024, is in the past or future relative to today.

Working with Times

The TIME function allows you to create a time value from hours, minutes, and seconds. This is useful for working with time intervals or event calculations.

The TIMEVALUE function converts a text string representing time into a numerical time value. This is useful if the time is recorded as text, but you need to work with it as a numerical value.

Syntax and Examples

TIME(hour, minute, second)

  • hour - The hour component of the time;
  • minute - The minute component of the time;
  • second - The second component of the time.

TIMEVALUE(time_string)

time_string - The string that holds the time representation.

FormulaResultComment
TIME(14, 30, 0)2:30:00 PMCreates the time 14:30:00 (2:30 PM), where hours, minutes, and seconds are specified.
TIME(9, 45, 30)9:45:30 AMCreates the time 9:45:30 (AM).
TIME(0, 0, 0)12:00:00 AMReturns midnight (00:00:00), where all components are 0.
TIMEVALUE("14:30:00")2:30:00 PMThe text time "14:30:00" is converted to 2:30 PM.
TIMEVALUE("09:45:30 AM")9:45:30 AMThe text time "09:45:30 AM" is converted to 9:45 AM.
TIMEVALUE("11:30 AM")11:30:00 AMThe time "11:30 AM" is converted to the numerical format 11:30:00 AM.
IF(TIMEVALUE("5:59 PM") > TIMEVALUE("12:00 PM"), "Afternoon", "Morning")AfternoonThe condition checks if 5:59 PM is later than 12:00 PM and returns "Afternoon."

Extracting Year, Month, and Day

The YEAR function extracts the year from a date. This is useful when you need to separate the year for data analysis or filtering by year.

The MONTH function extracts the month from a date. This is useful for analyzing data by month or grouping data by months.

The DAY function returns the day of the month from a date. This is useful for filtering data by days or analyzing events that occurred on a specific day of the month.

Syntax and Examples

YEAR(date)

date - The date from which to calculate the year. Must be a cell reference to a cell containing a date, a function returning a date type, or a number.

MONTH(date)

date - The date from which to extract the month. Must be a reference to a cell containing a date, a function returning a date type, or a number.

DAY(date)

date - The date from which to extract the day. Must be a reference to a cell containing a date, a function returning a date type, or a number.

FormulaResultComment
YEAR(DATE(2024, 12, 31))2024Extracts the year 2024 from the date December 31, 2024.
MONTH(DATE(2024, 12, 31))12Extracts the month 12 (December) from the date December 31, 2024.
MONTH("12/31/2024")12Extracts the month 12 (December) from the date December 31, 2024, by another method.
DAY(DATE(2024, 12, 31))31Extracts the day 31 from the date December 31, 2024.
YEAR(TODAY())2024Returns the current year 2024 based on the TODAY function.
MONTH(TODAY())10Returns the current month (October) based on the TODAY function.
DAY(TODAY())1Returns the current day of the month (1) based on the TODAY function.
IF(MONTH(DATE(2024, 12, 31)) = 12, "December", "Not December")DecemberChecks if the month in the given date is December and returns "December."

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 6. Capítulo 9
We're sorry to hear that something went wrong. What happened?
some-alt