NursingCorp
asked on
VB.NET parse datetime string to get just time
Assistance getting a value out of a datetime string using VB.NET,
We start with a string for the startTime = 1/8/2009 5:30:00 AM
How do I parse this string to get the hour of the time (i.e. 5)
then, parse the string to get the minutes (i.e. 30)
then, parse the string to get the AM/PM part
and then convert it based on,
if the minutes = 00, set the newStartTime = 5.0
if the minutes = 30 set the newStartTime = 5.5
if the AM/PM were PM, then add 12 to hours so that newStartTime = 17.5
I am new to computer programming, and have been trying to learn via books and online videos.
Thanks,
Joe
We start with a string for the startTime = 1/8/2009 5:30:00 AM
How do I parse this string to get the hour of the time (i.e. 5)
then, parse the string to get the minutes (i.e. 30)
then, parse the string to get the AM/PM part
and then convert it based on,
if the minutes = 00, set the newStartTime = 5.0
if the minutes = 30 set the newStartTime = 5.5
if the AM/PM were PM, then add 12 to hours so that newStartTime = 17.5
I am new to computer programming, and have been trying to learn via books and online videos.
Thanks,
Joe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks everyone.
http://articles.techrepublic.com.com/5100-10878_11-6089546.html
Here is an example they gave:
Dim Hour As DateTime = DateTime.Hour
MessageBox.Show(Hour)