ASP.NET / VB: Value of this hour as an integer

I want the value of this hour as an Integer (not a string).

This does NOT work:

<%@ Page Language="VB" AutoEventWireup="false" %>
<% 

Dim THour As Integer = DateTime.Now.ToInt32("H")
Response.Write(THour)

%>

Open in new window

LVL 16
hankknightAsked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
This may be clumsy but it appears to do it.
<% 
Dim Ctime = DateTime.Now
Response.Write(Ctime & "<br>")
Dim Htime = DateTime.Now.ToString("HH:mm:ss")
Response.Write(Htime & "<br>")
Dim Hnum = CInt(Hour(Htime))
Response.Write(Hnum & "<br>")
%>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.