Subject Re: [firebird-support] Seconds precision in TIMESTAMP fields (was: Transaction isolation problem?)
Author Helen Borrie
At 07:14 PM 26/02/2010, you wrote:
>>> Nevermind. Found the problem using ISQL - apparently Firebird 2.1
>>> changes TIMESTAMP precision from seconds to 0.0001 seconds, which is
>>> causing difference between my OLD.MODIFIED_ON (4 decimal places
>>> precision) and NEW.MODIFIED_ON (rounded down to seconds).
>>>
>> You must be talking about the CURRENT_TIMESTAMP subsecond precision (not the TIMESTAMP data type).
>>
>I _AM_ talking about the TIMESTAMP data type (or, more precisely, a
>domain TDATETIME defined as CREATE DOMAIN TDATETIME TIMESTAMP): I have a
>number of TIMESTAMP fields in my tables and I want to be certain all of
>them are only used with seconds precision.

What I mean is, the DATA in those timestamp fields is coming from reading CURRENT_TIMESTAMP.


>>> Can I force a timestamp precision in Firebird 2.1 to follow Firebird 1.5
>>> rules?
>>>
>> In 1.5, in the time part of CURRENT_TIMESTAMP and in CURRENT_TIME you got 4 places of decimal for sub-seconds, but the value was always .0000.
>>
>> From Firebird 2 onward, you get 3 places of decimal for sub-seconds but you get the actual value. You cannot go back to .0000, but you can set the precision for CURRENT_TIMESTAMP and CURRENT_TIME to be zero places of decimal, using
>>
>> CURRENT_TIMESTAMP(0)
>> CURRENT_TIME(0)
>>
>> It is in the release notes and in the Inst. and Migration Guide, by the way.
>>
>Unfortunately, it's not what I need.
>
>1) Just about everywhere in my application 'now' is used,

That's a problem, I think. As far as I know, 'NOW' in v.2 conforms to the same new rule as CURRENT_TIMESTAMP but it doesn't allow the zero precision. So, while you could capture CURRENT_TIMESTAMP(0) and store it the way you want (without seconds precision) you can't currently do the same with the 'NOW' value.

>so I would
>need to rewrite that to (current_date+current_time) (I can't use
>CURRENT_TIMESTAMP(0) because I need to be sure that my application work
>with both Firebird 1.5 and 2.1). That is possible, of course, but it
>will not help me much if someone (a DB administrator accidentally uses
>'now' in a query because, simply because he is used to write 'now'
>rather than the other method).

Do you realise that 'NOW' and CURRENT_TIMESTAMP are not the same?


>2. What I actually need is a DATE/TIME datatype which uses a seconds
>precision. As far as I know, Firebird doesn't have one so I am forced to
>use TIMESTAMP, which worked fine in Firebird 1.5 but is too precise for
>my needs in Firebird 2.1.

You could put in a feature request. I wouldn't hold my breath though: you are asking to have a fixed bug deliberately regressed! Unfortunately for you, it has *never* been a good idea to design a known bug into your code. As is often said, "some day it will bite you."

./heLen