• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

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

0
hankknight
Asked:
hankknight
1 Solution
 
Dave BaldwinFixer 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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now