Function is_time
The function checks strings for being a time.
You might pass a second parameter to use a format string. Without the format, the default format of PostgreSQL is used.
There has been a behaviour change in PostgreSQL 10. A conversion is now handled strict, as in previous versions the conversion tried to calculate time.
Examples
/**
* Parameter is in PostgreSQL default format
*/
SELECT is_time('14:33:55.456574') AS res;
Result:
| res |
|---|
| t |
SELECT is_time('25:33:55.456574') AS res;
Result:
| res |
|---|
| f |
/**
* Parameter is some time format
*/
SELECT is_time('14.33.55,456574', 'HH24.MI.SS,US') AS res;
Result:
| res |
|---|
| t |
SELECT is_time('25.33.55,456574', 'HH24.MI.SS,US') AS res;
Result:
| res |
|---|
| f |