Subject Re: [firebird-support] Is it possible to insert an INTEGER
Author Svein Erling Tysvaer
Helen Borrie wrote:
> At 05:08 PM 15/09/2007, you wrote:
>> I know that we can save time values to a time field as follows:
>> insert into test(T) values('10:15:00.0000')
>>
>> But how (if possible) do I save the time's integer value? For example:
>> Note: 10:15 a.m. equals 369000000
>> insert into test(T) values('369000000')
>>
>> In my application, I am working directly with Firebird's time fields
>> corresponding integer value. Since the time value is already in
>> integer form, I would be easy and eficient to just store the integer,
>> thus eliminating a conversion to FB followed a FB conversion back to
>> integer before saving to disk.
>>
>> If this is not possible, I will just convert the integer into the
>> corresponding time string each time I need to save a time value.
>
> It's not possible. But if you store two timestamps as start value
> and end value, you can get the interval between them and calculate
> the seconds and milliseconds difference between those. Of course,
> this mightn't be as useful as your Plan B, of storing a clock time as
> a time and having a trigger calculate its value into an integer field
> of tenths of thousands of seconds since midnight.

What is possible, is to add to a time value. So, what does work, is:

insert into test(T) values(cast('00:00:00.0000' as time)+36900)

HTH,
Set