Reputation: 4829
i am using linq to fetch the data and converting time field into string.
At that time if i have a value 11:00:00 in time field of sql server.
But i am getting "Jan 1 1900 11:00AM" at the time of converting to string.
Please provide me help to fetch only time part.
Thanks in advance..
Upvotes: 0
Views: 576
Reputation: 233457
It sounds like the field is of type DateTime. You can use the TimeOfDay property to get only the time part.
timeField.TimeOfDay
Upvotes: 1
Reputation: 36031
Try this:
yourDateTimeObject.ToString("HH:mm:ss")
Or as Mark Seemann suggested:
yourDateTimeObject.TimeOfDay.ToString()
Upvotes: 1