converting sql datetime to just time in c#

  • Thread starter Thread starter M.Smith
  • Start date Start date
M

M.Smith

I am returning a datetime from SQL and need to populate a field with just
the time...

I have tried:

DateTime.Parse(TheTime.Hour.ToString()) + ":" +
DateTime.Parse(TheTime.Minute.ToString();



But that does not return the correct HOUW format.



Any suggestions?

Marty
 
M.Smith said:
I am returning a datetime from SQL and need to populate a field with just
the time...

I have tried:

DateTime.Parse(TheTime.Hour.ToString()) + ":" +
DateTime.Parse(TheTime.Minute.ToString();



But that does not return the correct HOUW format.



Any suggestions?

Marty

Hmm...so you want to put the time into a textbox?

txtTextBox.Text = TheTime.ToString("hh:MM")

I believe it is hh:MM, if not, try HH:MM.

Mythran
 
I am using C# and that does not work...it compiles with an error :

"No overload for method 'ToString' takes '1' arguments"

I will keep looking - any other suggestions I am open to...
 
Back
Top