Android Question How to Convert SQL.Time to hour,minute,second

newbie

Member
Licensed User
Longtime User
Hello,
need help to convert a sql.Timefield to Hours,minutes, second

I have try to read the field as long and then convert it with DateTime.GetHour
but this don't work.
Found nothing in the forum.

Thanks for Help
 

udg

Expert
Licensed User
Longtime User
If you're referring to a MySql Time column, please have a look here for its specifics.
Anyway, if you save time of day as hh:mm:ss in that column then you first have to read it back as a string and finally convert it by DateTime.TimeParse function which gives you the right number of ticks (date part is set to today). Only then you use functions to extract separately hours, minutes and seconds.

Beware of TimeFormat set in your app before parsing to avoid errors (it should be "HH:mm:ss" if that is what you read back from SQL).

udg
 
Upvote 0
Top