简体   繁体   中英

How do I split dates in the form of “Dec. 9, 2016” into three separate columns “12” “09” “2016” in Excel?

I have a column of dates in the format of Mmm. dd, yyyy that I'm trying to split into three separate columns, ones for day, month, and year.

I've tried the DATEVALUE function but it tells me that my input is in an improper format.

So say you have Jan. 9, 2016

  1. Highlight the column
  2. Go to the Data Tab
  3. Click on Text to Columns
  4. Follow the instructions

I have provided examples below, but im on my mac. It should look similar on windows and the process is the same.

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Final result:

在此处输入图片说明

Hope this helps

Solution 1 - Using formula

If your original date is always in the described structure, such as " Dec. 9, 2016 ", " Jan. 31, 2018 ", or " Jun. 25, 2017 ", then you can use excel formulas to find YEAR, DAY, and MONTH consecutively.

解决方案1

Here are the formulas:

To find YEAR: =--RIGHT(A2,4)

To find DAY: =--TRIM(MID(A2,LEN(A2)-7-MOD(LEN(A2),12),LEN(A2)-10))

To find MONTH: =MONTH(DATEVALUE(D2&"-"&LEFT(A2,3)&"-"&B2))

Solution 2 - Using Power Query

Alternatively, you can use Power Query to automatically recognize your original data as dates and split them into three columns as desired. See below steps:

解决方案2

Please note you need to have Excel 2010 or later versions to be able to use Power Query Editor.

Cheers :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM