Avatar of NursingCorp
NursingCorpFlag for United States of America

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


Editors IDEsVisual Basic.NETVisual Basic Classic

Avatar of undefined
Last Comment
NursingCorp
Avatar of MikeDiehn
MikeDiehn
Flag of United States of America image

This is a good article about the date time functions you have access to in VB.NET:

  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)

ASKER CERTIFIED SOLUTION
Avatar of thefarm
thefarm
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of psasik
psasik

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of NursingCorp
NursingCorp
Flag of United States of America image

ASKER

Thanks everyone.
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo