You can use the following formula to convert a date to a YYYYMMDD format in Google Sheets:

=TEXT(A1, "YYYYMMDD")

This will convert a date such as** 1/4/2023** to a format of **20230104**.

You can also use the following formula to insert dashes between the year, month and day:

=TEXT(A1, "YYYY-MM-DD")

This will convert a date such as** 1/4/2023** to a format of **2023-01-04**.

Note that each formula assumes the date is in cell **A1**.

The following example shows how to use each formula in practice.

**Example: Convert Date to YYYYMMDD Format in Google Sheets**

We can use the following formula to convert a date to a YYYYMMDD format in Google Sheets:

=TEXT(A2, "YYYYMMDD")

We can type this formula into cell **B2** and drag the formula down to every remaining cell in column B:

Column B displays each date in column A in a **YYYYMMDD** format.

For example:

- 1/4/2023 has been converted to 20230104.
- 1/6/2023 has been converted to 20230106.
- 2/3/2023 has been converted to 20230203.

And so on.

We can also insert dashes between the year, month and day by using the following formula:

=TEXT(A2, "YYYY-MM-DD")

We can type this formula into cell **B2** and drag the formula down to every remaining cell in column B:

Column B displays each date in column A in a **YYYY-MM-DD** format.

For example:

- 1/4/2023 has been converted to 2023-01-04.
- 1/6/2023 has been converted to 2023-01-06.
- 2/3/2023 has been converted to 2023-02-03.

And so on.

**Note**: You can find the complete documentation for the Google Sheets **TEXT** function here.

**Additional Resources**

The following tutorials explain how to perform other common tasks in Google Sheets:

Google Sheets: How to Extract Date from Text String

Google Sheets: How to Filter Dates by Month

Google Sheets: How to Find Most Recent Date