Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
761 views
in Technique[技术] by (71.8m points)

excel - How to convert all the datetimes into one standard format yyyy-mm-dd hh:mm:ss AM/PM in csv?

There are 2 datetime formats in same column of a csv file. How to convert all the datetimes into one standard format yyyy-mm-dd hh:mm:ss AM/PM?

a column of the csv having different datetime formats

question from:https://stackoverflow.com/questions/65950980/how-to-convert-all-the-datetimes-into-one-standard-format-yyyy-mm-dd-hhmmss-am

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems like your dates are in the wrong format. The dd (day-number) and mm (month) are swapped. Only dates with a dd <= 12 are (wrongly) converted, while months with a value > 12 are ignored and treated as text. Do not open the csv file in a normal way, but import it with the Text Import Wizard (Excel 2016):

  1. Create a new file and goto Data -> Get External Date -> From Text
  2. Import the csv file
  3. In step 2 choose the correct delimiter (probably Comma or Semicolon)
  4. In step 3 select the first column in the Data preview and choose Date with the format MDY (not DMY!)

Now the dates will be converted correctly.

  1. Select the column with the dates
  2. Now go to the Format Cells window by clicking the small arrow button in the bottom-right corner of the Alingment area on the Home tab. Select the date format you want.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...