Subject | Re: [firebird-support] Seconds precision in TIMESTAMP fields (was: Transaction isolation problem?) |
---|---|
Author | PenWin |
Post date | 2010-02-26T08:14:15Z |
Dne 26.2.2010 9:01, Helen Borrie napsal(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.
1) Just about everywhere in my application 'now' is used, 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).
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.
Thanks, Pepak
> At 05:53 PM 26/02/2010, you wrote:I _AM_ talking about the TIMESTAMP data type (or, more precisely, a
>
>> 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).
>
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.
>> Can I force a timestamp precision in Firebird 2.1 to follow Firebird 1.5Unfortunately, it's not what I need.
>> 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.
>
1) Just about everywhere in my application 'now' is used, 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).
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.
Thanks, Pepak