Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
Code:
DIm n_date as date
Dim xst as date
Dim xet as date
Dim en as long
With worksheet("Test")
st = 7/24
et = 15/24
n_date = 44033
xst = n_date + st 'serial date + time
xet = n_date + et 'serial date + time
.Cells(2 9) = Format(xst, "h:mm am/pm")
.Cells(2, 10) = Format(xet, "h:mm am/pm")
End With
With this code,
xst=44033.2916666666666667
xet=44033.625
Cell I2 displays 7:00 am. In the formula bar is displays as 7:00:00 AM
Cell J2 displays 3:00 pm. In the formula bar is displays as 3:00:00 PM
It appears as though these two cells have lost the date portion of the values xst and xet assigned to them. I'm not sure why the value changed, my intent was to keep the value (date + time) in the cell but format them only to reveal the time portion.
What must I do to retain the date portion as well as reference to the date portion will be needed at some point.
NXP