Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert mysql strings into seconds?
How to convert mysql strings into seconds?
Just follow the format of hours, minutes and seconds and decimal.

I haven't studied mysql, so the code can't help you write mysql.

I will use SQL.

statement

@times

Char(8) defines a variable.

statement

@h

Int// hour

statement

@m

Int// min

statement

@s

Int// sec

statement

@ Seconds Count

Bigint// big plastic surgery

//initialization

a set of

@times='20:32: 13 '

//Conduct detailed data processing.

@ h = convert (substring (@ Times, 1, 2), int)// Extract the hour information from the string tiems and convert it into int type.

@ m = convert (substring (@ times,4,2),int)//min。

@ s = convert (substring (@ times,7,2),int)//sec。

@ secondcount = ((@ h/60)+m)/60+s//Convert hours into minutes and calculate the total number of minutes, then divide by 60 to get seconds, and finally calculate the total number of seconds.

choose

@ Seconds Count

be like

"Convert to seconds ="