Str2time

sql

FUNCTION Str2time(IN s CHAR(n)) RETURNS TIME;

Parameters

s character string containing a hour:minute
, hour:minute:second
or hour:minute:second.thousandth entry notation
tm output parameter: time

Description

The Str2time function converts the date entry from the s string into the Time type value and returns the value. Empty string will be converted into NULL. You may also the similar CAST SQL function.

Function value

The function returns the time entry (in SQL) if the time notation is the (only) content of the s string, otherwise NONETIME (NULL in SQL).

Examples of strings that can be converted

SET str = '12:34:56.789';
SET str = '0:34';

Examples of strings that cannot be converted

SET str = '12:20 PM';
SET str = '25:00';

See