-1

Ive been having some trouble with this for a while. I want to be able to retrieve values of time stored in my database (as type time). I've tried:

reader.getDateTime("open_hours")

I just get an error. I've also tried converting the string into time but i can only convert it into datetime, meaning that i have the date as well as the time. How can i get just the time (in 24 hour format)?

aLeXaNdRa08
  • 29
  • 1
  • 1
  • 8

1 Answers1

3

you can use this link

for example:-

Dim strTime As String = "3:00 PM"

' Convert to datetime

Dim dtTime As DateTime = Convert.ToDateTime(strTime)
' Display in 24hr format

Response.Write(dtTime.ToString("HH:mm"))

example2:-

string militaryTime;
string originalTime = "3:11 PM";
DateTime dt;
if (DateTime.TryParse(originalTime, out dt))
    militaryTime = dt.ToString("HH:mm");
Pradnya Bolli
  • 1,915
  • 1
  • 19
  • 37