Converting Date to Time --- Please Help!

PatrickMilano21

New Member
Joined
Jun 17, 2015
Messages
10
I used the function: MRound(Cells(i, 1).Value, 1 / 24), to round each of my dates to the nearest hour. I now have cells that look like the following: (1/1/2014 12:00:00 AM), (1/1/2014 1:00:00 AM), (1/1/2014 2:00:00 AM)..... ETC.

How do I write a program that extracts JUST THE HOUR. SO for the examples above I would get:

12:00:00, 1:00:00, and 2:00:00.

Please help!!! Thank you!!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
If the above was helpful you could (should) say so, and others searching for the same solution will know this worked, plus it gives the user who helped you positive feedback.

Just sayin'
 
Upvote 0
Hey SpillerBD, thank you so much for replying! I tried to use that before, but for some reason it was not helping

I ended up using: =TIME(HOUR(A1),MINUTE(A1),SECOND(A1)). I am going to try to use yours again though! Thank you so much for responding!
 
Upvote 0
=HOUR(DateTimeRef)
This function gives the numerical value of the hours as an integer from 0 to 23

However if you want the time you actually need:
=TIMEVALUE(TEXT(DateTimeRef,"HH:MM:SS"))
Make sure the cell is formatted to display as a time format such as "h:mm:ss"

(Yeah, it kept bothering me....)
 
Upvote 0
This function gives the numerical value of the hours as an integer from 0 to 23

However if you want the time you actually need:
=TIMEVALUE(TEXT(DateTimeRef,"HH:MM:SS"))
Make sure the cell is formatted to display as a time format such as "h:mm:ss"

(Yeah, it kept bothering me....)



I see, that makes perfect sense. Great, thanks again SpillerBD!
 
Upvote 0

Forum statistics

Threads
1,216,740
Messages
6,132,445
Members
449,728
Latest member
teodora bocarski

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