Second() format :05 not :5

guybrown

Board Regular
Joined
Jul 2, 2008
Messages
100
Hi

The following returns 12:34:6 (note 6 not 06)
=CONCATENATE(HOUR(A1),":",MINUTE(A1),":",SECOND(A1))

Any ideas on how I can get 06?

Cheers,

Guy

It's ok, I've got it thanks all!

=HOUR(A1)&":"&MINUTE(A1)&":"&IF(LEN(SECOND(A1))=1,"0"&SECOND(A1),SECOND(A1))
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
To answer your question specifically (this will also work for the MINUTE section as well):

TEXT(SECOND(A1),"00")

I'm guessing your cell A1 has time AND date in it. You can use =A1-INT(A1) to extract just the time portion and then format with normal cell formatting unless of course you want it as text.
 
Upvote 0
Why not use the TEST function in place of the whole formula

=TEXT(A1,"h:m:ss")

(although if you want 2:09:34 instead of 2:9:34 "h:mm:ss" should be used.)
 
Upvote 0
Thanks all. I appreciate your repsonses.

The TEXT function is a lot simpler and covers minutes as well. Cheers.
 
Upvote 0

Forum statistics

Threads
1,224,575
Messages
6,179,637
Members
452,934
Latest member
Jdsonne31

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