|
From: John V. S. <js...@gm...> - 2008-06-20 01:27:14
|
David W wrote: > I wonder if there is a similiar function in LucidDB like > "time_to_sec(..)" in SQL. I checked > http://pub.eigenbase.org/wiki/LucidDbAppLib but I did not find this > function. > > > > Anybody knows how to handle "time_to_sec()" in LucidDB? There's no builtin yet, but it's easy to construct your own: create schema your_schema; create or replace function your_schema.time_to_sec(t time) returns integer deterministic contains sql return ( cast(applib.time_to_char('H', t) as integer)*3600 + cast(applib.time_to_char('mm', t) as integer)*60 + cast(applib.time_to_char('ss', t) as integer) ); select your_schema.time_to_sec(time '01:02:03') from (values(0)); +---------+ | EXPR$0 | +---------+ | 3723 | +---------+ Documentation for the underlying function is available here: http://pub.eigenbase.org/wiki/LucidDbAppLib_TIME_TO_CHAR SQL:2003 also supports an EXTRACT expression to do something similar, but it's not fully implemented in LucidDB. JVS |