{"id":4058,"date":"2019-01-30T11:10:06","date_gmt":"2019-01-30T11:10:06","guid":{"rendered":"http:\/\/officetuts.net\/excel\/?p=4058"},"modified":"2024-03-26T11:28:47","modified_gmt":"2024-03-26T11:28:47","slug":"convert-text-or-number-to-date","status":"publish","type":"post","link":"https:\/\/officetuts.net\/excel\/examples\/convert-text-or-number-to-date\/","title":{"rendered":"Convert Text or Number to Date in Excel"},"content":{"rendered":"\n
In this lesson, I\u2019ll\nshow you how to convert text to dates in Excel in a formula and non-formula\nway.<\/p>\n\n\n\n
When you import data to Excel, it may come in many different\nforms, with different delimiters. It\u2019s also important to be aware of dates\nnotation used in a particular country.\nFor example, people in the USA use different date format<\/a>\nthan the rest of the world.<\/p>\n\n\n\n There are many ways to convert text to date<\/a>. I\u2019ll show you all of them so you can choose a conversion technique that is most suitable in a given situation.<\/p>\n\n\n\n It\u2019s impossible to\nknow whether a particular value is a date or text by looking at a spreadsheet.\nYou have to check them. We can do it by using the ISTEXT<\/a>\nfunction.<\/p>\n\n\n\n This function returns TRUE<\/strong>\nif the value is text, and FALSE<\/strong>\notherwise. <\/p>\n\n\n\n Take a look at the following example. In column A<\/strong>, there are dates, but some of them\nare formatted as text and the other ones as dates.<\/p>\n\n\n\n If you press Ctrl + `<\/strong>\n(grave accent), you are going to notice how these values are stored.<\/p>\n\n\n\n You can also check whether\nthe text is formatted as a date by clicking it and looking at Home >> Number<\/strong>.<\/p>\n\n\n\n You have to be careful here. If you place a single\napostrophe (\u2018) before date (or any other value or formula), Excel will treat it\nas text, even when the number format in Home\n>> Number<\/strong> shows DATE<\/strong>.<\/p>\n\n\n\n This apostrophe will be only visible inside the formula bar<\/a>\nand not in a cell. The ISTEXT<\/strong>\nfunction will return TRUE<\/strong>.<\/p>\n\n\n\n There is no DATE<\/strong>\ntype in Excel. Dates are numbers formatted<\/a> to dates.<\/p>\n\n\n\n The following example has numbers in column A<\/strong>, and the same numbers formatted as\ndates in column B<\/strong>. Increasing the\nnumber by 1, increases the date by one day, starting from 1\/1\/1900<\/strong>.<\/p>\n\n\n\n If you want to know more about the way Excel stores dates read the following article<\/a>.<\/p>\n\n\n\n I\u2019m going to show you two ways you can change the date format<\/a>.\n<\/p>\n\n\n\n If you want to change the date format and then convert it to\ntext, you can do it with the TEXT function<\/a>.<\/p>\n\n\n\n This function converts a value\nto text in a specific format.<\/p>\n\n\n\n If you want to change the format of existing dates<\/a>, without\nconverting them to text, you can do it by accessing the Format Cells window.<\/p>\n\n\n\n Select the cells you want to change the format and press Ctrl + 1<\/strong>.<\/p>\n\n\n\n Under the Date<\/strong>\ncategory, you can choose a country and a format you want to use. Choose d-m-yyyy<\/strong>.<\/p>\n\n\n\n This is the result we get.<\/p>\n\n\n\n If you have a date in a form of text, you can\u2019t change it to\ndifferent date format. First, you have to convert it to a number and then to date<\/a>.<\/p>\n\n\n\n The DATEVALUE function<\/a>\ntakes a single argument, which is a date in a form of text.<\/p>\n\n\n\n Then the function converts this text to a number. The number\ncan be later converted to date with different date format.<\/p>\n\n\n\n If you want to change a date to a number, you can use the VALUE function<\/a> instead.<\/p>\n\n\n\n When you receive a file with dates written as an 8-digit\nnumber, first you have to recognize the country date\nformats<\/a> (YMD, DMY, MDY). If you have many examples, it’s easy to figure it out.<\/p>\n\n\n\nCheck whether a value is a DATE or\nTEXT<\/h2>\n\n\n\n
How to convert a number to date<\/h2>\n\n\n\n
Change the date format<\/h2>\n\n\n\n
Use the TEXT function <\/h3>\n\n\n\n
=TEXT(A2,\"dd-mm-yyyy\")<\/pre>\n\n\n\n
Format Cells window<\/h3>\n\n\n\n
Change text to date<\/h2>\n\n\n\n
=DATEVALUE(A2)<\/pre>\n\n\n\n
Convert 8-digit number to date<\/h2>\n\n\n\n