Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do you convert

Datetime.UTCnow.Hour

to a double?

UTChour = Cdbl(Datetime.UTCnow.Hour)
UTChour = Cdbl(Datetime.UTCnow.ToString("HH"))

do not work.
Posted

1 solution

It should - UTCNow returns a standard DateTime, and Hour just returns an integer - so CDbl will just convert the int32 to a double value.
And a quick check here:
VB
Dim d As Double = CDbl(DateTime.UtcNow.Hour)

Says it works just fine...d contains 18.0, and it's 19:26 BST, which is GMT+1, or UTC+1 if you prefer...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900