Hexycode
Hexycode

Reputation: 458

Change the YYYY-MM-DD HH-PM/AM date to same date with 24 hour format

Got a question about how I can change a date/time format in Excel.

I have this format 2020-05-29 06-PM and I need to change it to be like this YYYY-MM-DD HH:MM

I have a table of above 20000 lines which is needed to be changed.

I already try to do like this - =TEXT(A3,”YYYY:MM:DD HH”)’ and I receive an #ERROR! Any suggestion on how can I do it?

Also important note that I'm using excel spreadsheets in Google Drive. If it's even possible to make in Google Drive Excel spreadsheets or should I use regular Excel on my PC?

EDIT1 I have a first column like this and I did accordingly to @Gary'sStudent answer and I it goes strange in one way.

2020-05-29 06-PM
2020-05-29 05-PM
2020-05-29 04-PM
2020-05-29 03-PM
2020-05-29 02-PM
2020-05-29 01-PM
2020-05-29 12-PM
2020-05-29 11-AM
2020-05-29 10-AM
2020-05-29 09-AM
2020-05-29 08-AM
2020-05-29 07-AM
2020-05-29 06-AM
2020-05-29 05-AM
2020-05-29 04-AM
2020-05-29 03-AM
2020-05-29 02-AM
2020-05-29 01-AM
2020-05-29 12-AM
2020-05-28 11-PM
2020-05-28 10-PM
2020-05-28 09-PM
2020-05-28 08-PM

Transforms to this

2020-05-29 06-00
2020-05-29 05-00
2020-05-29 16-00
2020-05-29 15-00
2020-05-29 14-00
2020-05-29 13-00
2020-05-30 00-00
2020-05-29 23-00
2020-05-29 22-00
2020-05-29 09-00
2020-05-29 08-00
2020-05-29 07-00
2020-05-29 06-00
2020-05-29 05-00
2020-05-29 04-00
2020-05-29 03-00
2020-05-29 02-00
2020-05-29 01-00
2020-05-29 12-00
2020-05-28 11-00
2020-05-28 10-00
2020-05-28 21-00
2020-05-28 20-00

Why it goes like 16:00/15:00 when it's supposed to go 04:00 and 03:00 accordingly?

Upvotes: 0

Views: 563

Answers (2)

Chris
Chris

Reputation: 943

try this:

=TEXT(A1,"YYYY-MM-DD [hh]-mm")

or same format in Custom Format [CTRL]+[1]

Upvotes: 0

Gary's Student
Gary's Student

Reputation: 96753

With data in A1, in another cell enter:

=DATEVALUE(LEFT(A1,10))+TIME(MID(A1,12,2),0,0)+IF(RIGHT(A1,2)="PM",TIME(12,0,0),0)

and format as you require:

enter image description here

NOTE:

There are three parts:

  • DATEVALUE() gets the date
  • TIME() gets the hour
  • IF() bumps by 12 hours if required

Format is 24 hr.

EDIT#1:

Here is the full posted data set with the output in column C:

enter image description here

Upvotes: 1

Related Questions