Adding 8 hours to a time.

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
In my userform, I enter 8:00 into textbox 'cu2_start'. This represents 8:00 AM.

Code:
 etc_cu2 = format(CDate(cu2_start.Value), "0.00000")
This line converts the text time to a decimal time value ... in this case etc_cu2 = "0.33333"

Code:
hj = etc_cu2 + 8
cu2_end.Value = format(hj, "hh:mm")

I am failing with my attempts with the code above to add 8 hours to 'etc_cu2' in order to have 16:00 (4:00 PM) into textbox cu2_end. 'cu2_end' displays as 08:00 with this code.

Can anyone suggest a solution to the problem I am having?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Possibly...
Code:
hj = etc_cu2 + 8 / 24

or

Code:
hj = DateAdd("h", 8, etc_cu2)
 
Last edited:
Upvote 0
Hi Mark ...
Yep! That was exactly what I was needing. Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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