简体   繁体   中英

Need to convert a specific text format to date format MM/DD/YYYY

I have an export from Active Directory of user accounts in a .csv/Excel where the date created cell is of General format (text?) as follows: 20150903075605.0Z in cell A1 which I need to convert to Date format as MM/DD/YYYY . I believe the text translates into 2015/09/03 but I could be wrong.

What I have tried so far:

  1. Remove the .0Z and it changes to 2.01509E+ 13 . Then in the neighboring cell ( B1 ) I try =DATE(A1) which gives me a #VALUE
  2. Tried =DATE(LEFT(C2,2)+100,MID(C2,3,2),RIGHT(C2,2)) but that gives me an obscure date of 4/12/2020 .

This formula coverts the value in A1 into a true number:

=DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2))

You should apply number formatting to the cells where the formula is used. The number formatting would be: mm/dd/yyyy . In Excel, number formatting is often the best way to deal with dates.

If you need text instead of a true date, then:

=MID(A1,5,2)&"/"&MID(A1,7,2)&"/"&LEFT(A1,4)

假设20150903075605.0Z包含在单元格A1 ,那么您可以通过以下连接获得 MM/DD/YYYY 日期格式:

mid(A1, 5, 2) & "/" & mid(A1, 7, 2) & "/" & left(A1, 4)

So here is what I did to fix this. First strip the .0Z out.

Cell A2: 20040330191012 converting this to date (MM/DD/YYYY) in B2 by typing in =DATE(MID(C2,1,4),MID(C2,5,2),MID(C2,7,2)) gives me 3/30/2004.

I am pretty sure this is correct but if one of you guru's can confirm, it would be deeply appreciated.

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