Sql Firebird将整数转换为时间或日期

Sql Firebird将整数转换为时间或日期,sql,firebird,firebird2.5,Sql,Firebird,Firebird2.5,我有一个表,它将秒数存储为整数。 我想显示它并将其用作时间或日期 如果我这样写: Select Cast(ColAmountofSeconds as Time) as ThisTime From MyTable; 同: Select Cast(ColAmountofSeconds as Date) as ThisTime From MyTable; 我得到以下错误: 数据类型转换期间发生溢出。来自的转换错误 字符串“14” 注“14”是ColAmountofSeconds列中第一行的值 这在

我有一个表,它将秒数存储为整数。 我想显示它并将其用作时间或日期

如果我这样写:

Select Cast(ColAmountofSeconds as Time) as ThisTime From MyTable;
同:

Select Cast(ColAmountofSeconds as Date) as ThisTime From MyTable;
我得到以下错误:

数据类型转换期间发生溢出。来自的转换错误 字符串“14”

注“14”是ColAmountofSeconds列中第一行的值

这在SQL Server中是如此自然,以至于我无法相信我花了这么多时间来解决这个问题

编辑

我不敢相信这是答案:

Update MyTable
Set TIMESPENT =  time '00:00:00' + ColAmountOfSeconds;
Firebird不支持将数值转换为日期、时间或时间戳

您可以利用Firebird支持日期和数值之间的算术关系这一事实,因此您可以这样编写查询:

select dateadd(second, ColAmountOfSeconds, cast('00:00:00' as time))
  from myTable;

--or the equivalent:

select cast(cast('2013-01-01' as timestamp) + cast(ColAmountofSeconds as double precision) / 86400 as TIME)
  from myTable;

是的,你说得对,你是在我编辑问题的同时发布的。
time'00:00:00
是相当于
cast('00:00:00'作为时间)