Google Sheets: The Complete Guide to All Date Functions

Published on

Understanding DATE functions is crucial for mastering most data manipulation techniques, as time is indispensable. Whether summarizing data based on date grouping, plotting charts, or highlighting expiry dates, date functions play a crucial role in various analytical tasks.

Welcome to our comprehensive guide on mastering all available date functions in Google Sheets under one roof.

TODAY Function

When you want to display the current date in a cell, use this function.

=TODAY()

Remember, the date inserted will recalculate based on changes in the sheet. You can control the recalculation by navigating to File > Settings > Calculation.

NOW Function

The NOW function in Google Sheets is similar to the TODAY function. While the TODAY function returns only the current date, the NOW function returns the current date and time. It’s important to note that both functions are volatile, meaning they update continuously, and the recalculation settings that apply to TODAY also apply to NOW.

=NOW()

DAY Function

Use the DAY function to return the day component of a given date or timestamp.

Syntax:

=DAY(date)

Argument:

  • date – The date from which to extract the day.

Examples:

=DAY(TODAY()) // will return the day component from today's date
=DAY(A1) // will return the day component from the given date in cell A1.

If cell A1 is empty, the formula will return 30, because the value in an empty cell is 0, and dates are stored as serial numbers, where 0 is equivalent to 30/12/1899.

How do you return a blank with the DAY function if the cell is empty?

Wrap the cell reference with the DATEVALUE function and the DAY function within an IFERROR function as follows:

=IFERROR(DAY(DATEVALUE(A1)))

MONTH Function

The MONTH function returns the month component of a given date or timestamp in Google Sheets.

Syntax:

=MONTH(date)

Arguments:

  • date – The specific date from which to extract the month.

Examples:

=MONTH(TODAY()) // will return the month component from today's date
=MONTH(A1) // will return the month component from the given date in cell A1.

If cell A1 is empty, the formula will return 12, for the reason already cited under the DAY function.

How do you return a blank with the MONTH function if the cell is empty?

Wrap the cell reference with the DATEVALUE function and the MONTH function within an IFERROR function as follows:

=IFERROR(MONTH(DATEVALUE(A1)))

YEAR Function

The YEAR function returns the year component from a given date or timestamp.

Syntax:

=YEAR(date)

Arguments:

  • date – The date from which to extract the year.

Examples:

=YEAR(TODAY()) // will return the year component from today's date
=YEAR(A1) // will return the year component from the given date in cell A1.

The year component of an empty cell will be 1899, as explained under the DAY function.

How do you return a blank with the YEAR function if the cell is empty?

Wrap the cell reference with the DATEVALUE function and the YEAR function within an IFERROR function as follows:

=IFERROR(YEAR(DATEVALUE(A1)))

DATE Function

Use the Google Sheets DATE function to convert a provided year, month, and day into a date. This function is often used in the criteria part of formulas like SUMIF, COUNTIF, etc.

Syntax:

=DATE(year, month, day)

Arguments:

  • year: The year component of the date.
  • month: The month component of the date.
  • day: The day component of the date.

Example:

=DATE(2024, 1, 25) // will return the date 25/01/2024.

DATEVALUE Function

We have already used the DATEVALUE function with DAY, MONTH, and YEAR above to address the blank cell issue.

The purpose of the DATEVALUE function in Google Sheets is to convert a provided date string in a known format into a date value.

Syntax:

=DATEVALUE(date_string)

Arguments:

date_string: The string representing the date.

Examples:

=DATEVALUE(TODAY()) // will return the date serial number of today's date.
=DATEVALUE("30/12/1899") // will return 0.
=DATEVALUE("31/12/1899") // will return 1.
=DATEVALUE(A1) // will return the date value of the date in cell A1. If A1 is empty, it will return a #VALUE! error.

Related: DATEVALUE Function in Google Sheets: Advanced Tips and Tricks

DAYS Function

You can utilize the DAYS function to find the difference in the number of days between two given dates.

Syntax:

=DAYS(end_date, start_date)

Arguments:

  • end_date: The end of the date range.
  • start_date: The start of the date range.

Assume cell A1 contains 20/05/2024 and cell B1 contains 25/05/2024. The following formula will return 5:

=DAYS(B1, A1)

This is equivalent to using =B1-A1.

How do you return a blank with the DAYS function if either cell is empty?

Wrap the cell references with the DATEVALUE function and the DAYS function within an IFERROR function as follows:

=IFERROR(DAYS(DATEVALUE(B1), DATEVALUE(A1)))

DAYS360 Function

The purpose of the DAYS360 function is to calculate the difference between two dates based on a 360-day year, primarily used in financial interest calculations.

Syntax:

DAYS360(start_date, end_date, [method])

Arguments:

  • start_date: The start date of the range.
  • end_date: The end date of the range.
  • method: Day count method indicator (optional).

Examples:

The method in these formulas is 1, which represents the European method. In this method, start dates and end dates that fall on the 31st day of a month are considered the 30th day of the same month.

=DAYS360("25/03/2018", "31/03/2018", 1) // returns 5
=DAYS360("29/02/2024", "01/03/2024", 1) // returns 2
=DAYS360("28/02/2023", "01/03/2023", 1) // returns 3

The ‘method’ in these formulas is 0, which represents the U.S. method.

=DAYS360("25/03/2018", "31/03/2018", 0) // returns 6
=DAYS360("30/03/2018", "31/03/2018", 0) // returns 0
=DAYS360("29/02/2024", "01/03/2024", 0) // returns 1
=DAYS360("28/02/2023", "01/03/2023", 0) // returns 1

In this method:

  • If the start_date is the last day of a month, it is considered the 30th day of the same month. Please refer to the last two formulas.
  • If the end_date is the 31st day of the month and the start_date is earlier than the 30th, the end_date is changed to the 1st day of the next month (as in the first formula above); otherwise, the end_date is changed to the 30th day of the same month (as in the second formula above).

To address the empty cell issue in the DAYS360 function, follow the IFERROR and DATEVALUE approach as follows:

=IFERROR(DAYS360(DATEVALUE(A1), DATEVALUE(B1), 1))

EDATE Function

The EDATE function in Google Sheets returns a date that is a specified number of months before or after a provided start date.

Syntax:

=EDATE(start_date, months)

Arguments:

  • start_date: The initial date from which to calculate the new date.
  • months: The number of months before (-) or after (+) the start_date to calculate.

Examples:

=EDATE(A1, 5)
=EDATE(A1, -5)

Assume cell A1 contains the date 10/01/2024. The first formula will return the date 10/06/2024, whereas the second formula will return the date 10/08/2023.

If cell A1 is empty, the formula =EDATE(A1, 5) will return 30/05/1900, whereas =EDATE(A1, -5) will return a #NUM! error.

Use the DATEVALUE and IFERROR functions with EDATE to return a blank cell when the start date is empty:

=IFERROR(EDATE(DATEVALUE(A1), 5))

Then format the result to Format > Number > Date.

ISOWEEKNUM Function

Returns the number of the ISO week of the year for a given date.

Syntax:

=ISOWEEKNUM(date)

To understand this Google Sheets function, you should first know what an ISO Week is. This Wikipedia article provides detailed information about ISO Weeks.

ISO Week in a Nutshell:

  • The ISOWEEKNUM function follows the ISO 8601 date and time standard.
  • In this standard, weeks begin on Monday and end on Sunday.
  • According to this standard, Week #1 of the year is the week that contains the first Thursday of the year.

Please refer to the table below.

DateWeekdayISO Week #Remarks
1/1/21Fri53
2/1/21Sat53
3/1/21Sun53
4/1/21Mon1
5/1/21Tue1
6/1/21Wed1
7/1/21Thu1First Thursday
8/1/21Fri1
9/1/21Sat1
10/1/21Sun1
11/1/21Mon2

The ISOWEEKNUM function will return 52 as the week number if the referenced cell is empty. To solve this, follow the example below:

=IFERROR(ISOWEEKNUM(DATEVALUE(A1)))

NETWORKDAYS Function

You can utilize the NETWORKDAYS function in Google Sheets to get the working days between two dates.

Syntax:

=NETWORKDAYS(start_date, end_date, [holidays])

Arguments:

  • start_date: The starting date of the period.
  • end_date: The ending date of the period.
  • holidays: [Optional] A range or array constant containing the dates to consider as holidays.

When returning the result, the formula excludes dates that fall on Saturday, Sunday, and any specified holidays.

Please refer to the image below for an example.

Examples of the NETWORKDAYS function in Google Sheets

To return an empty cell when either the start or end date is empty in the NETWORKDAYS function in Google Sheets, you can adjust the formula as follows:

=IFERROR(NETWORKDAYS(DATEVALUE(A2), DATEVALUE(B2), C2:C11))

NETWORKDAYS.INTL Function

The NETWORKDAYS.INTL function is similar to the NETWORKDAYS function, with the additional capability of allowing you to specify which days of the week are considered weekends.

Syntax:

=NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays])

Arguments:

  • start_date: The starting date of the period.
  • end_date: The ending date of the period.
  • weekend: [Optional – 1 by default] A number or string specifying weekends.

Number Method:

Weekend #Weekend
1Saturday & Sunday
11Sunday
2Sunday & Monday
12Monday
3Monday & Tuesday
13Tuesday
4Tuesday & Wednesday
14Wednesday
5Wednesday & Thursday
15Thursday
6Thursday & Friday
16Friday
7Friday & Saturday
17Saturday

String Method:

This method specifies weekends using seven 0s and 1s, representing Monday to Sunday. 1 represents weekends and 0 represents workdays.

“0000000” represents all working days, while “0000011” represents Saturday and Sunday as weekends.

  • holidays: [Optional] A range/array containing the dates to consider as holidays.

Examples:

Assume cell A1 contains 01/01/2024 and B1 contains 31/12/2024. The holidays are 01/01/2024 and 25/12/2024 in C1:C2.

=NETWORKDAYS(A1, B1, C1:C2)
=NETWORKDAYS.INTL(A1, B1, "0000011", C1:C2)
=NETWORKDAYS.INTL(A1, B1, 1, C1:C2)

All the above formulas will return 260, excluding the two holidays and the Saturday & Sunday weekends.

With the NETWORKDAYS.INTL function, you can specify weekends of your choice.

Regarding handling empty cell issues in NETWORKDAYS.INTL, please follow the same DATEVALUE and IFERROR approach we adopted in NETWORKDAYS.

Example:

=IFERROR(NETWORKDAYS.INTL(DATEVALUE(A1), DATEVALUE(B1), "0000011", C1:C2))

WORKDAY Function

We can use the WORKDAY function in Google Sheets to get the end date after a specified number of working days, excluding Saturday and Sunday weekends and selected holidays.

Syntax:

=WORKDAY(start_date, num_days, [holidays])

Arguments:

  • start_date: The date from which to begin counting.
  • num_days: The number of working days to advance (if positive) or backward (if negative).
  • holidays: [Optional] A range/array containing the dates to consider as holidays.

Example:

Assume cell A1 contains the date 24/05/2024, which falls on a Friday. The following formula will return 27/05/2024, which falls on a Monday.

=WORKDAY(A1, 1)

To exclude holidays in addition to weekends, enter the holidays in a range, for example, C1:C10, and specify that range in the formula.

=WORKDAY(A1, 20, C1:C10)

If the specified cell is empty, the WORKDAY formula will return an invalid date. To return an empty result, follow this:

=IFERROR(WORKDAY(DATEVALUE(A1), 20, C1:C10))

Apply the Format > Number > Date formatting to the result cell.

WORKDAY.INTL Function

You can use the WORKDAY.INTL function to return a date by advancing a specified number of workdays, excluding specific weekends and holidays.

Syntax:

=WORKDAY.INTL(start_date, num_days, [weekend], [holidays])

Arguments:

  • start_date: The date from which to begin counting.
  • num_days: The number of working days to advance (if positive) or backward (if negative).
  • weekend: [Optional – 1 by default] A number or string specifying weekends. See the NETWORKDAYS.INTL function above for details.
  • holidays: [Optional] A range/array containing the dates to consider as holidays.

Examples:

Cell A1 contains 24/05/2024, which falls on a Friday.

=WORKDAY(A1, 1) // will return 27/5/2024, Monday
=WORKDAY.INTL(A1, 1) // will return 27/05/2024, Monday
=WORKDAY.INTL(A1, 1, "0000001") // will return 25/05/2024, Saturday

In the last formula, only Sunday is considered a weekend. Additionally, you can specify holidays in these formulas.

=WORKDAY(A1, 20, C1:C10) // Saturday & Sunday are weekends
=WORKDAY.INTL(A1, 20, "0000011" ,C1:C10) // Saturday & Sunday are weekends
=WORKDAY.INTL(A1, 20, "0000001", C1:C10) // Sunday is a weekend

In these formulas, C1:C10 contains the holidays.

If the specified cell is empty, the WORKDAY.INTL formula will return an invalid date. To return an empty result, follow this:

=IFERROR(WORKDAY.INTL(DATEVALUE(A1), 20, "0000001", C1:C10))

Apply the Format > Number > Date formatting to the result cell.

YEARFRAC Function

The YEARFRAC function is another useful date function. It returns the number of years, including fractional years, between two given dates.

Syntax:

=YEARFRAC(start_date, end_date, [day_count_convention])

Arguments:

  • start_date: The start date of the date range.
  • end_date: The end date of the date range.
  • day_count_convention: [OPTIONAL – default is 0] The method used to calculate the fraction of a year.

The day_count_convention parameter determines how the fraction of the year is calculated, with the following options:

  • 0: Indicates 30 days for each month, resulting in 360 days in a year (30/360).
  • 1: Indicates the actual number of days between the two specified dates (actual/actual).
  • 2: Indicates the actual number of days between the two specified dates but assumes a 360-day year (actual/360).
  • 3: Indicates the actual number of days between the two specified dates but assumes a 365-day year (actual/365).
  • 4: Similar to 0, but adjusts end-of-month dates according to European financial conventions (European 30/360).

Examples:

Examples of the YEARFRAC function in Google Sheets

Also Refer:

Day count convention (External Source)

Note: To handle the empty cell issue in YEARFRAC, use the DATEVALUE and IFERROR combination, similar to most date functions in Google Sheets.

Here is one example:

=IFERROR(YEARFRAC(DATEVALUE(A1), DATEVALUE(B1), 1))

DATEDIF Function

The DAYS function returns the number of days between two dates, whereas the DATEDIF function returns the number of days, months, or years between two dates.

Syntax:

=DATEDIF(start_date, end_date, unit)

Arguments:

  • start_date: The start date to consider in the calculation.
  • end_date: The end date to consider in the calculation.
  • unit: A text abbreviation for the unit of time. The possible values are:
    • "Y": Returns the number of whole years.
    • "M": Returns the number of whole months.
    • "D": Returns the number of days.
    • "MD": Returns the number of days after subtracting whole months.
    • "YM": Returns the number of whole months after subtracting whole years.
    • "YD": Returns the number of days between the start date and the end date, assuming the start date and end date are no more than one year apart.

Examples:

In all the examples below, the date in cell A1 is 1-Jan-2024 and the date in cell B1 is 2-Feb-2025.

=DATEDIF(A1, B1, "Y")   // Returns 1 (whole year)
=DATEDIF(A1, B1, "M")   // Returns 13 (whole months)
=DATEDIF(A1, B1, "D")   // Returns 398 (days)
=DATEDIF(A1, B1, "MD")  // Returns 1 (days after subtracting whole months)
=DATEDIF(A1, B1, "YM")  // Returns 1 (whole months after subtracting whole years)
=DATEDIF(A1, B1, "YD")  // Returns 32 (days between start and end date within one year)

Note: If the start_date is empty, the DATEDIF function will return a #NUM error.

WEEKDAY Function

The WEEKDAY function in Google Sheets returns a number representing the day of the week for the provided date.

Syntax:

=WEEKDAY(date, [type])

Arguments:

  • date: The date for which to determine the day of the week.
  • type: [Optional – defaults to 1]
    • 1: Numbering starts from 1 to 7, where 1 is Sunday and 7 is Saturday.
    • 2: Numbering starts from 1 to 7, where 1 is Monday and 7 is Sunday.
    • 3: Numbering starts from 0 to 6, where 0 is Monday and 6 is Sunday.

Examples:

A1 contains the date 01/01/2024, which falls on a Monday:

=WEEKDAY(A1, 1) // returns 2
=WEEKDAY(A1, 2) // returns 1
=WEEKDAY(A1, 3) // returns 0

To handle the scenario where an empty cell returns a weekday number of 5, 6, or 7 depending on the specified type, follow this workaround to return an empty cell instead:

=IFERROR(WEEKDAY(DATEVALUE(A1), 1))

WEEKNUM Function

Given a date input, the WEEKNUM function returns the week number in the year the date falls.

Syntax:

=WEEKNUM(date, [type]

Arguments:

  • date: The date that determines the week number.
  • type: [OPTIONAL – default is 1]. Types are 1, 2, 11 to 17, and 21. Here is the breakdown:

In the following types, the week containing January 1st is numbered week 1:

TypeStartEnd
1SundaySaturday
2MondaySunday
11MondaySunday
12TuesdayMonday
13WednesdayTuesday
14ThursdayWednesday
15FridayThursday
16SaturdayFriday
17SundaySaturday

In the ISO 8601 standard (type 21), the week containing the first Thursday of the year is numbered week 1.

TypeStartEnd
21MondaySunday

Examples:

In the following examples (screenshot), the following formulas in cells C2 and E2 are dragged/copied down:

=WEEKNUM(A2, 2) // C2 formula
=WEEKNUM(A2, 21) // E2 formula
Examples of the WEEKNUM function in Google Sheets

If the specified cell is empty, the WEEKNUM function will return 52 or 53, depending on the type specified. You can follow the example below to return an empty cell instead:

=IFERROR(WEEKNUM(DATEVALUE(A1), 1))

EOMONTH Function

The EOMONTH function returns the last date of the month that falls on the same month as the given date or a specified number of months before or after the given date.

Syntax:

=EOMONTH(start_date, months)

Arguments:

  • start_date: The date to convert to the end of the month date.
  • months: The number of months before or after the start_date.

Examples:

=EOMONTH(TODAY(), 0) // Returns the end of the month date in the current month
=EOMONTH(TODAY(), -1) // Returns the end of the month date in the previous month
=EOMONTH(TODAY(), 1) // Returns the end of the month date in the next month

If the ‘months’ argument is a positive number and the cell is empty, the EOMONTH function will return an unwanted result. To address this issue, follow this example:

=IFERROR(EOMONTH(DATEVALUE(A1), 5))

Apply Format > Number > Date to format the result as a date.

For more detailed information, you can refer to the tutorial: EOMONTH Function in Google Sheets: All About

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

More like this

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

72 COMMENTS

  1. Hello! I loved this and have saved it for future use. Unfortunately, what I was originally looking for isn’t on it, and I am hoping you might be able to help.

    I have two sheets. One sheet has pay dates, and the second sheet is bills with their due dates. I want to auto-highlight the bills on sheet 2 that fall between one payday and the next from sheet 1. I know I can use a formula and manually add the two dates, but I’d like to have the formula refer to the actual cell since the dates will change every month.

    I know it will be a custom formula, but I’m stuck on how to refer to a cell on the other sheet.

    In my head, it goes like this:

    If column F on sheet 2 is before cell A2 on sheet 1, then highlight the entire row on sheet 2.

    Thank you!!!

    • To refer to another sheet, you need to use INDIRECT in conditional formatting.

      Here is the rule that you can try, assuming the sheet names are Sheet1 and Sheet2:

      =AND(ISDATE($F1), LT($F1, INDIRECT("Sheet1!A2")))

  2. How can I pull the date from the month, year, and weekday? Think of a calendar view. I need to build a formula that pulls the month (January), year (2023), and weekday (Monday) to pull the date (January 2). I imagine that I need to include the week number somewhere, which is fine. I appreciate your help!

    • Assume that cells B2, B3, and B4 contain the month text, year, and weekday text, respectively.

      For example:

      Cell B2 contains the text “February”.
      Cell B3 contains the number 2023.
      Cell B4 contains the text “Monday”.

      Then you can try the following formula:

      =LET(mon,LET(dt,DATE(B3,MONTH(B2&1),1),dt-WEEKDAY(dt,2)+
      MATCH(B4,{"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"},0)),
      IF(MONTH(mon)=MONTH(B2&1),mon,mon+7))

  3. I have a data set in a Google Sheet that captures employee time off requests for vacation, sick days, etc.

    The data includes a Start Date column and an End Date column.

    For example, someone is requesting vacation from 1/1/2023 to 1/15/2023.

    I am trying to identify dupes (i.e., overlapping dates).

    For example, if that same person enters another record later on for vacation from 1/10/2023 to 1/15/2023, we know that is impossible – they can’t be off “twice” on the same days.

    What is the best way to capture those types of duplicates?

    It’s not just the values on the columns, but the data range in between.

    Thanks,
    Ken

    • Hi, KenW,

      We can expand those dates using one of the new Lambda helper functions and find such duplicates.

      I have such a tutorial in the pipeline. If you share a sample of your Sheet, I may consider writing my formula/tutorial around that problem.

  4. Hi!

    I would like to create a header in my spreadsheet with the days of the month in increments of two days from 1-29, starting with the TODAY function; for 3 months.

    I can do it for the first month by setting TODAY in the first cell and then adding two to the next cell over, copying it into the rest of the row up to 29.

    Is there a function I can use to refer back to the first cell and start this sequence again in the next month (1-29), and then again in the third month?

    Thanks for any help you can give.

    • Hi, Elizabeth Hatch,

      Give this array formula a try.

      Assume the first date is in cell A1.

      =lambda(final,filter(final,final<>""))({ifna(lambda(data,
      filter(data,data<=date(year(A1),month(A1),min(29,day(eomonth(A1,0)))))) (sequence(1,16,A1+2,2))),lambda(data,filter(data, data<=date(year(eomonth(A1,0)+1),month(eomonth(A1,0)+1), min(29,day(eomonth(eomonth(A1,0)+1,0))))))(sequence(1,16,eomonth(A1,0)+1,2)),lambda(data, filter(data,data<=date(year(eomonth(A1,1)+1), month(eomonth(A1,1)+1),min(29,day(eomonth(eomonth(A1,1)+1,0)))))) (sequence(1,16,eomonth(A1,1)+1,2))})

      It requires a blank row to populate the dates.

  5. Hello! I would like to enter a date of a document that needs to be redone every 6 months.

    At 5 months, I would like it to highlight yellow, and at the 6-month point, I would like it to be highlighted red.

    Can I do this?

  6. Hi there,

    I wonder if you can help me with my dilemma.

    I have a list of dates and values.

    I want to calculate the average values in a range for the last 7 “workdays” – a 7-day running average.

    I can do it with the calculation of today -7 days, but I can’t get it to work with workday(cell ref, -7 workdays).

    • Hi, Zman,

      Assume the criteria range (date) is column C (C1:C) and the average range is column B (B1:B).

      Then try this formula which uses the newly introduced MAP function.

      =AVERAGEIF(map(C1:C,lambda(wd,iferror(and(workday(wd-1,1)=wd,isbetween(wd,WORKDAY(today(),-7),today()))))),TRUE,B1:B)

  7. Hello, Thanks for your hard work.

    I want to restrict users to select the date only three days from the current date.

    If the user entered date is more than three days, the system has to show a pop-up error message and not accept the date in the column.

    If the date is below three days, the system has to accept the date in the column.

    Please guide me on how to set the above condition in Google sheets.

    • Hi, B4ALLB4U,

      You can do it as follows.

      Select the cells and go to Data > Data validation > Criteria > Date > On or before.

      Enter the following formula in the given field.

      =today()+3

      Check “Reject Input” and “Save.”

  8. Thank you very much for this Effort.

    I want to find the “LOW” Price of a particular stock for a given month.

    Tried your “high” formulae in the same manner for getting low but were unable.

    =index(sortn(GoogleFinance($A$1,"high",B118, C118,"DAILY"),2,1,2,0),2,2)

    $A$1 = STOCK SYMBOL
    B118 = 3/2/2022
    C118 = 3/31/2022

    • Hi, Yagnesh Darji,

      I assume you were trying to find the MIN of the above historical data, not the low price for the specified date(s).

      If so, try this.

      =index(sortn(GoogleFinance($A$1,"high",B118, C118,"DAILY"),1,1,2,1),0,2)

  9. Thank you for this tutorial! I may have missed where I can auto-populate due dates from the event date. For example,

    The event date is April 25, 2022, and is located in cell D1.

    I have 25 tasks to complete before April 25 – these tasks are due in various increments – 30 days out; 25 days out; 5 days out… etc. and are listed in D4 through D21. Some will be + for tasks after the event.

    I need to auto-populate those due dates. What would my formula be?

    Thank you!

  10. Hi. Thank you for this. How would I formulate the start of a pay period and the end of a pay period given the pay date?

    Let’s say the pay date is Friday, Jan 14th, 2022.

    I want my sheet to auto-populate the pay period start date (Saturday, Jan 1st, 2022) and the pay period end date (Friday, Jan 7th, 2022) by itself.

    I want my sheet to recognize the start date as Saturday and the end date as Friday.

    • Hi, GJ,

      Let’s assume the pay date is in D4.

      To get the payment period, use the below formulas.

      Start: =(D4-weekday(D4)+6)-13

      End: =(D4-weekday(D4)+6)-7

      If the above doesn’t help, please share a few more examples in your reply.

  11. You’re a wizard. Here’s my problem. I would be so appreciative.

    Looking to add to dates (e.g., =A1+7), but if the end date is a weekend or holiday, push it to the next workday.

    My difficulty is that WORKDAY and adding holidays to it will not count them *within* the seven days, but I want to include them, but not if it’s the 7th day itself.

    Assume I can array holidays and if needed, weekends.

    Thank you in advance!

  12. Hi! This was so helpful.

    I’m looking to measure Projected Date vs. Actual Date.

    B1 (Projected Date) = 1/26/22
    C1 (Actual Date) = 1/27/22

    The percentage is 100% if the dates are the same.

    If the dates are not the same, return the percentage.

    Thank you for your time and assistance!!

    • Hi, Lexi Maitland,

      This may possible if you have a start date.

      E.g.:
      A2 (Start Date)
      B2 (Projected Completion Date) = 1/26/22
      C2 (Actual Completion Date) = 1/27/22
      D2 (Duration in Percentage)

      =to_percent(days(C2,A2)/days(B2,A2))

      It will return 100% if the dates are the same.

  13. Hello, I am trying to make a formula that allows me to select a date from the sheets’ calendar but can’t do it. (I want to be able to click on a shell and then get a calendar to select the date)

    Thank you in advance, and have a great 2022!

  14. Hi, I love this tutorial. I was able to use some of the functions.

    I just have questions on how I can compute if on cell A1 I have a specific date, and on cell B1, I have 6 (represents six months).

    How can I have A1 +B1 = C1?

    Like A1 (1-19-2021) + B1 (6 months) = C1 (7-19-2021)

    I hope you can help me. Thank you.

  15. Hi,

    I am looking for a formula to validate whether the given DOB falls in 18 years to 45 years or not?

    It should be through validation, and if he doesn’t fall in the 18 to 45 years range, show validation help text “You are not eligible.”

    Thanks

    • Hi, Nitin Jain,

      Assume the cell in question is B2.

      Go to DATA > Data Validation. Choose the Criteria “Custom formula is” and enter the below rule in the given field there.

      =and(
      isdate(B2),
      gte(datedif(B2,today(),"Y"),18),
      lte(datedif(B2,today(),"Y"),45)
      )

      You can learn the use of the GTE and LTE functions here – Comparison Operators in Google Sheets and Equivalent Functions.

      Note:- To apply the rule to a range like B2:B100, just change the “Cell range” accordingly within the Data Validation dialogue box. The formula will be the same.

  16. Hello,

    The tutorial was great. I used a few formulas already.

    I am trying to find a way to calculate how many projects are past their renewal dates. So I have column A with dates, and I want to calculate how many projects are past today’s date, automatically without changing the date each time. Is there a way to calculate a total?

  17. Hi Prashanth,

    You helped me out with the formula below. Is it possible to select two weeks from a selected date?

    =ArrayFormula(sumifs(D5:D,B5:B,B2,month(C5:C),C2))

    Cheers
    Steve

    • Hi, Steven Umpleby,

      You can try this formula.

      =ArrayFormula(sumifs(D5:D,B5:B,B2,C5:C,">="&C2,C5:C,"<="&C2+14))

      Note:- Please replace the earlier formula (month number) with the below one.

      =ArrayFormula(sumifs(D5:D,B5:B,B2,datevalue(C5:C),">0",month(C5:C),C2))

  18. Trying to calculate how many days it takes us to complete our job process.

    We currently add a new job every day.

    I am using NETWORKDAYS – Column A contains our start date and Column B contains our finish date.

    This works great as long as there is a date entered into the “finish date” field.

    If we have not completed this task, it shows up as a -31580.

    These jobs are not completed in numerical order.

    Is there a way to have the NETWORKDAYS formula ignore blank fields in the hopes of alleviating the negative numbers as well as the need to update the formula in that field, every time a process is completed?

    Any help?

  19. Hoping you can help me.

    I’ve read through your entire article and my head is spinning.

    We own a storage yard for containers to be stored. We have to charge customers from the day they begin to store a container here to the day it leaves our yard.

    When I enter the start date and the end date and use the =DAYS or =DATEDIF, OR =MINUS(A2,B2) the result is not including the day they begin.

    For example, 1/1/2021 – 1/7/2021 is calculating 6 days when we would bill 7 days.

    • Hi, kris hart,

      The date difference between 01/01/2021 and 01/01/2021 will be 0.

      So, if A1 contains 01/01/2021 and B1 contains 02/01/2021 (both in DD/MM/YYYY format as per my sheets’ formatting), the following formula will return 1.

      =days(B1,A1)

      To make both the dates inclusive, modify the formula as below.

      =days(B1,A1)+1

  20. Hi, I need help with Google Sheets formatting of dates.

    If I have two columns:
    Column E – to be filled with dates
    Column F – 90 days from date in Column E

    How can I get Column F to be filled in automatically when I key in dates in Column E?

    • Hi, Carmen,

      If you start entering the dates from E2 (in E2:E as cell E1 may contain a label), then you can try the below array formula.

      =ArrayFormula(TO_DATE(IFERROR(if(DATEVALUE(E2:E),E2:E+90,))))

      Empty column F and insert the formula in cell F2.

  21. Hi, Can you help me find a formula for my Google Sheets?

    Example:
    A1: 160000
    A2: 15000
    A3: =(date)
    A4: =sum(A1-A2) starting from cell A3

    I need to subtract cell A2 from cell A1 every 30 days into cell A4.

  22. Hi,

    I have a column from Google Sheets with a date on it. Column B.

    I need Column A to calculate the date to show the Monday of that week.

    I have this formula that works, B2-WEEKDAY(B2,3), but I need to make it an array so it auto-fills. How can I do this?

  23. Hello,

    I am trying to display the $ value present in a cell associated with the last day of each month given a daily $ value is collected in a spreadsheet each day. How can you only collect that last day of each month (12 values) among 365 values in a year?

    • Hi, Hardest Easy,

      Assume the said two columns are A2:A (dates) and B2:B (dollar values). The cells A1 and B1 contain the labels.

      If so, try this formula.

      =array_constrain(sort(sortn(sort({A2:B,month(A2:A)},1,0),9^9,2,3,0)),9^9,2)

      The formula must be adjusted as per your LOCALE settings as detailed here – How to Change a Non-Regional Google Sheets Formula.

      If you want the formula explanation, please mention that in your reply.

  24. I’ll try to explain my problem, please help.

    Id of Crew|Name|In|Out|D.Hrs|Night D.Hrs
    N10001|AAA|05-06-2020 16:00|05-06-2020 23:00|07:00|01:00 (btn 22 to 06)
    N10002|BBB|06-06-2020 23:00|07-06-2020 08:00|09:00|08:00 (btn 22 to 06)
    N10006|XYX|08-06-2020 03:00|09-06-2020 23:30|20:30|03:00 (btn 22 to 06)
    N10010|LMN|08-06-2020 21:00|08-06-2020 23:45|02:45|01:45 (btn 22 to 06)

  25. I would like to turn a cell red if it is five years from the date listed in the cell. Is this possible with google sheets?

  26. Hello,

    Could anybody help me?

    I want calculating night duty Hrs between two date-time. i.e.,

    One who joining his duty at dd/mm/yyyy 10:00:00 hrs and out from duty at dd/mm/yyyy 04:45:00 hrs.

    I want to calculate how many Hrs having worked between 22:00 to 06:00 between joining and outing his duty. (excel sheet or Google Sheet only).

  27. I’m trying to keep up with my monthly dues, and on my Google Sheet, I want the whole row to be highlighted if the due date is today.

    I know how to highlight the whole row, but I don’t know how to automatically change the date on the cell.

    For example, I would initially enter January 26 in the cell. After January 26, I want it to change to February 26 so that in conditional formatting, I can highlight any row with today’s date (every 26th).

  28. Hello,

    Could you help me?

    I have a dashboard that shows the running totals of sales for the day, week and month.

    I have managed to program formula for day & week but I am struggling with calculating sales in the current month.

    My data is set out with a transaction date in column A and transaction total in column I.

    This set of data is continually updated through an automated workflow integration.

    To calculate weekly total I use this formula: sum(filter(Zapier!I:I,weeknum(Zapier!A:A,2)=weeknum(today(),2)))

    Is there a formula that would do the same for a monthly total?

    Thank you in advance for your assistance

  29. Hi Prashanth,

    I thought your response to Anakowi on June 16, 2019, might provide the answer for which I’ve been searching!

    Unfortunately, though, when I plugged it into my Google Sheets document, it did not work as I’d hoped. I’ll explain what I need and hopefully, you can advise me accordingly! Thanks, so much, in advance!!

    So, I’ve created a file to include all of the coupons and sales ads, including item type, brand, store, sale amount, and each coupon’s date of expiration.

    What I want to have happened is… whenever the expiration date is TODAY, the cell is (let’s say) RED. When it is within the next 7 days, I want the cell to be GREEN. If the expiration date is 7-14 days from today, I want it to be YELLOW.

    I’ve now tried your suggestion to the most recent poster, as well as another blogger’s suggestion, which is as follows:

    Format Rules –> Format Cells if — >
    Custom Formula IS –>

    =if(WEEKNUM((INDIRECT("B"&ROW())))=WEEKNUM((TODAY()+7), 1), 1,0)=1

    Formatting Style –>

    YELLOW (Fill Bucket color selection)

    However, neither option has worked… am I missing something or what do you suggest?

    Thanks in advance!

    • Hi, Erin,

      I have a similar tutorial here – How to Highlight Cells Based on Expiry Date in Google Sheets.

        Now to your particular requirement.

      I have my expiry dates in B2:B. Here are the conditions and custom formulas to highlight B2:B based on expiry.

      Condition 1: Highlight the cell to Red, if the expiration date is Today.
      Formula Rule 1: =B2=today()
      Note: If you want to highlight multiple columns, I mean B2:Z instead of B2:B, use it as =$B2=today().

      See this guide for detailed info – Highlight an Entire Row in Conditional Formatting in Google Sheets.

      Condition 2: Expiry date is within the next 7 days, I want the cell to be in Green.
      Formula Rule 2: =and(B2>today(),B2<=today()+7)

      Condition 3: If the expiration date is 7-14 days from today, I want to highlight the cell to Yellow.
      Formula Rule 3: =and(B2>today()+7,B2<=today()+14)

  30. Thank you, Prashanth. This info has been so useful.

    I’m now stuck trying to automate the display of a date based on TODAY’s date to use with other calculations. I want the display date to always be “Friday” (start_date) and only changes when the next Friday is reached.

    For example, today is Sat, 15 June 2019. So the display date will be Fri, 14 June 2019 until the next Friday arrives, i.e., Fri, 21 June 2019. Is it possible?

    I’ve tried using WEEKNUM as the closest method to set Friday as the first day of the week, but it’s not giving me the result I need.

  31. I’m trying to set my utility bills schedule and the dates to show the upcoming payment date. So If the BILLING DATE is past the CURRENT DATE it should change the MONTH to the next.

    Any help would be appreciated,

  32. Thanks for your extremely useful article. Could I get your help in getting a couple of dates as below?

    1. The date of the Friday last week

    2. The date of the Friday Last month.

    Much Appreciated.

    Vijay

  33. Hi, thanks for this. Very useful. Any clue how to enter a function that will always display the date of a particular upcoming day? For example, I want a cell to display the date of next Tuesday up to and including that Tuesday. On the Wednesday after that Tuesday I want it to display the following Tuesday’s date.

    • Hi, Seth,

      Welcome to InfoInspired!

      You can try the below formula. Replace the cell reference G1 with weekday numbers. 1 represents Sunday, 2 for Monday and so on. If you put 1 in G1 or replace G1 with 1, the formula would populate the dates from today to coming Sunday.

      =ArrayFormula(if(weekday(today())>G1,row(indirect("A"&TODAY()&":"&today()-weekday(today())+7+G1)),row(indirect("A"&TODAY()&":"&today()-weekday(today())+G1))))

      Cheers!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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