Change date format

mIkeChchNZ

New Member
Joined
Jul 13, 2024
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I have a report that returns the date and time as Friday, July 12, 2024 07:08:00 p.m.

Is there a formula or macro I can use to change this to display as d/mm/yyy h:mm

Friday, July 12, 2024 07:08:00 p.m.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
What produces the report? Is it output from a macro, or are you just using the standard Excel printing to print a page?
 
Upvote 0
The report is run through a software package we use at work and is exported as an excel sheet.
 
Upvote 0
Format only works on numerical data. Is your data numerical data or is it text? Check with =ISNUMBER().
 
Upvote 0
Says false so would this mean I need to separate each component and convert it somehow?
 
Upvote 0
Yes. Here's a formula (assumes date in A1) but that would need to go in another cell. You could set the text colour of the original to white to hide it.
Excel Formula:
=TEXT(LET(ldate,TRIM(TEXTSPLIT(A1,",")),DATE(LEFT(CHOOSECOLS(ldate,3),4),MONTH(1&TEXTBEFORE(CHOOSECOLS(ldate,2)," ",1)),TEXTAFTER(CHOOSECOLS(ldate,2)," ",1)))+LET(ftime,TEXTAFTER(CHOOSECOLS(TRIM(TEXTSPLIT(A1,",")),3)," "),htime,TEXTBEFORE(ftime,":"),TIME(IF(TEXTAFTER(ftime," ")="p.m",VALUE(TEXTBEFORE(ftime,":"))+12,TEXTBEFORE(ftime,":")),MID(ftime,4,2),MID(ftime,7,2))),"d/mm/yyyy, h:mm")
@Cubist will come up with a better one :)

A VBA solution could change the original cell value so if you prefer that let us know.
 
Upvote 0
Try this. After inserting the formula, you'll see numbers. That's just how Excel stores dates, but you can format cell -> custom.
Book1
AB
1Textd/mm/yyy h:mm
2Friday, July 12, 2024 07:08:00 p.m.12/07/2024 19:08
Sheet2
Cell Formulas
RangeFormula
B2B2=--TEXTAFTER(SUBSTITUTE(A2,".","")," ")
 
Upvote 0
Thanks, that's one hell of a formula. Tried it and it works but doesn't show in 24hr format. Would I just need to change h:mm to [h]:mm?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top