Excel convert date to excel number

  • Редакция Кодкампа

17 авг. 2022 г.
читать 2 мин


В этом руководстве объясняется, как преобразовать дату в число в трех различных сценариях:

1. Преобразуйте одну дату в число

2. Преобразуйте несколько дат в числа

3. Преобразование даты в количество дней с другой даты

Давайте прыгать!

Пример 1: преобразование одной даты в число

Предположим, мы хотим преобразовать дату «10.02.2022» в число в Excel.

Для этого мы можем использовать функцию ДАТАЗНАЧ в Excel:

=DATEVALUE("2/10/2022")

По умолчанию эта функция вычисляет количество дней между заданной датой и 01.01.1900 .

На следующем снимке экрана показано, как использовать эту функцию на практике:

Это говорит нам о том, что между 10.02.2022 и 01.01.1900 существует разница в 44 602 дня.

Пример 2. Преобразование нескольких дат в числа

Предположим, у нас есть следующий список дат в Excel:

Чтобы преобразовать каждую из этих дат в число, мы можем выделить диапазон ячеек, содержащих даты, затем щелкнуть раскрывающееся меню «Числовой формат » на вкладке « Главная » и выбрать « Число »:

Это автоматически преобразует каждую дату в число, представляющее количество дней между каждой датой и 01.01.1900 :

Пример 3. Преобразование даты в количество дней, прошедших с другой даты

Мы можем использовать следующую формулу для преобразования даты в количество дней, прошедших с другой даты:

=DATEDIF( B2 , A2 , "d")

Эта конкретная формула вычисляет количество дней между датой в ячейке B2 и датой в ячейке A2 .

На следующем снимке экрана показано, как использовать формулу DATEDIF для расчета количества дней между датами в столбце A и 01.01.2022:

Вот как интерпретировать значения в столбце B:

  • Между 01.01.2022 и 01.04.2022 есть 3 дня.
  • Между 01.01.2022 и 01.01.2022 8 дней.
  • Между 01.01.2022 и 15.01.2022 14 дней.

И так далее.

Дополнительные ресурсы

В следующих руководствах объясняется, как выполнять другие распространенные задачи в Excel:

Как автозаполнять даты в Excel
Как использовать СЧЁТЕСЛИМН с диапазоном дат в Excel
Как рассчитать среднее значение между двумя датами в Excel


This tutorial explains how to convert a date to a number in three different scenarios:

1. Convert One Date to Number

2. Convert Several Dates to Numbers

3. Convert Date to Number of Days Since Another Date

Let’s jump in!

Example 1: Convert One Date to Number

Suppose we would like to convert the date “2/10/2022” to a number in Excel.

We can use the DATEVALUE function in Excel to do so:

=DATEVALUE("2/10/2022")

By default, this function calculates the number of days between a given date and 1/1/1900.

The following screenshot shows how to use this function in practice:

This tells us that there is a difference of 44,602 days between 2/10/2022 and 1/1/1900.

Example 2: Convert Several Dates to Numbers

Suppose we have the following list of dates in Excel:

To convert each of these dates to a number, we can highlight the range of cells that contain the dates, then click the Number format dropdown menu on the Home tab and choose Number:

This will automatically convert each date to a number that represents the number of days between each date and 1/1/1900:

Example 3: Convert Date to Number of Days Since Another Date

We can use the following formula to convert a date to a number of days since another date:

=DATEDIF(B2, A2, "d")

This particular formula calculates the number of days between the date in cell B2 and the date in cell A2.

The following screenshot shows how to use the DATEDIF formula to calculate the number of days between the dates in column A and 1/1/2022:

Here’s how to interpret the values in column B:

  • There are 3 days between 1/1/2022 and 1/4/2022.
  • There are 8 days between 1/1/2022 and 1/9/2022.
  • There are 14 days between 1/1/2022 and 1/15/2022.

And so on.

Additional Resources

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

How to AutoFill Dates in Excel
How to Use COUNTIFS with a Date Range in Excel
How to Calculate Average If Between Two Dates in Excel

Return to Excel Formulas List

Download Example Workbook

Download the example workbook

This tutorial will demonstrate how to convert a date to a serial number corresponding to that date (or vis-a-versa) in Excel and Google Sheets

Date Number Main Function

Date to Number

To convert a date to a serial number, all you need to do is change the formatting to General:

date to number excel

However, this won’t work if the date is stored as text.

Date Stored as Text to Number

If the date is stored as text, you can use DATEVALUE convert it to an Excel date:

=DATEVALUE(B3)

DATEVALUE Function

Then you can change the formatting to general to see the serial number.

Number to Date

To convert a serial number to a date, all you need to do is the change the formatting from General (or Number) to a date format (ex. Short Date):

number to date excel

Convert Date to Number in Google Sheets

All of the above examples work exactly the same in Google Sheets as in Excel.

GOOGLE GIF

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less

This article describes the formula syntax and usage of the DATEVALUE function in Microsoft Excel.

Description

The DATEVALUE function converts a date that is stored as text to a serial number that Excel recognizes as a date. For example, the formula =DATEVALUE(«1/1/2008») returns 39448, the serial number of the date 1/1/2008. Remember, though, that your computer’s system date setting may cause the results of a DATEVALUE function to vary from this example

The DATEVALUE function is helpful in cases where a worksheet contains dates in a text format that you want to filter, sort, or format as dates, or use in date calculations.

To view a date serial number as a date, you must apply a date format to the cell. Find links to more information about displaying numbers as dates in the See Also section.

Syntax

DATEVALUE(date_text)

The DATEVALUE function syntax has the following arguments:

  • Date_text    Required. Text that represents a date in an Excel date format, or a reference to a cell that contains text that represents a date in an Excel date format. For example, «1/30/2008» or «30-Jan-2008» are text strings within quotation marks that represent dates.

    Using the default date system in Microsoft Excel for Windows, the date_text argument must represent a date between January 1, 1900 and December 31, 9999. The DATEVALUE function returns the #VALUE! error value if the value of the date_text argument falls outside of this range.

    If the year portion of the date_text argument is omitted, the DATEVALUE function uses the current year from your computer’s built-in clock. Time information in the date_text argument is ignored.

Remarks

  • Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.

  • Most functions automatically convert date values to serial numbers.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Data

11

3

2011

Formula

Description

Result

=DATEVALUE(«8/22/2011»)

Serial number of a date entered as text.

40777

=DATEVALUE(«22-MAY-2011»)

Serial number of a date entered as text.

40685

=DATEVALUE(«2011/02/23»)

Serial number of a date entered as text.

40597

=DATEVALUE(«5-JUL»)

Serial number of a date entered as text, using the 1900 date system, and assuming the computer’s built-in clock returns 2011 as the current year.

39634

=DATEVALUE(A2 & «/» & A3 & «/» & A4)

Serial number of a date created by combining the values in cells A2, A3, and A4.

40850

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Если в вашей ячейке лежит дата в виде текстовой строки, например, «8 март 2013», то для Excel это, естественно, не дата, а текст. Чтобы преобразовать текстовую дату в полноценную (читай – в числовой код даты, т.к. внутри Excel любая дата представлена именно числовым кодом), можно использовать специальную функцию ДАТАЗНАЧ (DATEVALUE). Она умеет превращать в нормальную дату различные текстовые варианты ее написания:

Превращение текстовой даты в полноценную с ДАТАЗНАЧ

Как видно из скриншота, проблемы с преобразованием будут только у англоязычных дат (если у вас установлен русский Excel), с падежами месяцев (ибо их нет в английском языке в принципе) и с совсем уж невнятными цифровыми наборами типа «18 3 17». Со всем остальным эта функция замечательно справляется.

Если для ввода дат была использована не точка или косая черта, а запятая (что часто бывает при использовании дополнительной цифровой клавиатуры), то придется сначала заменить запятую на точку с помощью функции ПОДСТАВИТЬ (SUBSTITUTE) и потом уже использовать функцию ДАТАЗНАЧ для преобразования получившегося текста в реальную дату:

Дата с запятыми

Ссылки по теме

  • Как Excel на самом деле хранит и обрабатывает даты и время
  • Как найти ближайший рабочий день функцией РАБДЕНЬ (WORKDAY)
  • Как вычислить разницу между двумя датами в днях, месяцах или годах

Понравилась статья? Поделить с друзьями:
  • Excel convert all text to number one
  • Excel convert all formulas to text
  • Excel contains this and this text
  • Excel contacts to android
  • Excel connector что это