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 to Number
To convert a date to a serial number, all you need to do is change the formatting to General:
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)
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):
Convert Date to Number in Google Sheets
All of the above examples work exactly the same in Google Sheets as in Excel.
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.
To change the cell format from date to number we convert the formatting into General Format in Microsoft Excel.
There are three different ways to change the formatting from date to number.
1st Shortcut Key
2nd Format Cells
3rd Command Button
Let’s take an example and understand how we can convert cell formatting from date to number or general formatting.
We have date in column D. In column E we will learn to convert the cell format from date to number through shortcut key, in column F through Format Cells and in Column G through Command button.
To change the cell formatting by using the Shortcut Key
Follow below given steps:-
- Select the range E3:E11.
- Press the key Ctrl+Shift+~ on your keyboard.
- Cells formatting will get convert into numbers.
To change the cell formatting by using Format Cells
Follow below given steps:-
- Select the range F3:F11 and press the key Ctrl+1 on your keyboard.
- A format Cells dialog box will appear.
- In the Number Tab, Click on General.
- We can see the formatting in sample preview.
- The function will convert the formatting into general formatting.
To change the cell formatting by using Command Button
Follow below given steps:-
- Select the range G3:G11.
- Go to Home Tab click on General in the Number group.
- Date format will get convert in General format.
These are the ways in which we can convert the cell formatting from date to number in Microsoft Excel.
If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook.
We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at info@exceltip.com