Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Please help me,
i am getting date time field from XML(2017-06-19T14:45:00:00)
But i need to get only time using vb.net

What I have tried:

Dim o As String = (info.Element("onairtime").Value)
Dim value As DateTimeOffset = DateTimeOffset.ParseExact(o, "yyyy-MM-dd\THH:mm:ss", CultureInfo.InvariantCulture)
Posted
Updated 19-Jun-17 21:51pm
Comments
Afzaal Ahmad Zeeshan 20-Jun-17 4:01am    
Where is the XML of your code? So that we can know how you are extracting it.

You can get the complete DateTime object and just extract the time value. Or you can parse the text string and ignore the numbers to the left of the T.
 
Share this answer
 
Comments
Member 12480796 20-Jun-17 3:29am    
please give me example
Richard MacCutchan 20-Jun-17 3:42am    
Example of What? Are you saying you do not know how to parse a simple string and extract a part of it? Or use a DateTime constructor?
Something like this:
VB
Dim date1 As Date = Date.Now
Console.WriteLine("the time is " + date1.TimeOfDay.Tostring())
Or for a string:
VB
Dim date2 As String = "2017-06-19T14:45:00:00"
Console.WriteLine("the time is " + date2.Split(New Char() {"T"c})(1))
 
Share this answer
 
v2

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