ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel vs VBA Dates (https://www.excelbanter.com/excel-programming/291124-excel-vs-vba-dates.html)

ExcelMonkey[_85_]

Excel vs VBA Dates
 
In excel I can create hourly dates over a 24 hour period that rang
from:

1/1/2002 0:00

to

1/1/2002 23:00

Thus it uses military time. By using the format m/d/yyyy h:mm an
adding 1/24 each hour.

But when I try this in VBA I get:

1/1/2004 0:00
1/1/2004 1:00:00 AM
1/1/2004 2:00:00 AM
1/1/2004 3:00:00 AM
1/1/2004 4:00:00 AM
1/1/2004 5:00:00 AM
1/1/2004 6:00:00 AM
1/1/2004 7:00:00 AM
1/1/2004 8:00:00 AM
1/1/2004 9:00:00 AM
1/1/2004 10:00:00 AM
1/1/2004 11:00:00 AM
1/1/2004 12:00:00 PM
1/1/2004 1:00:00 PM
1/1/2004 2:00:00 PM
1/1/2004 3:00:00 PM
1/1/2004 4:00:00 PM
1/1/2004 5:00:00 PM
1/1/2004 6:00:00 PM
1/1/2004 7:00:00 PM
1/1/2004 8:00:00 PM
1/1/2004 9:00:00 PM
1/1/2004 10:00:00 PM
1/1/2004 11:00:00 PM

Is there any way in VBA to express m/d/yyyy h:mm in military time?

Thank

--
Message posted from http://www.ExcelForum.com


ExcelMonkey[_86_]

Excel vs VBA Dates
 
Apparently when I use:

Debug.Print Format(CurrentHourlyDate, "m/d/yyyy h:mm")

it seems to work

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com