Subject Re: [ib-support] How can I convert TIMESTAMP to DOUBLE PRECISION???
Author Nando Dessena
Lester,

> > It could be just me, but I still don't get it.
> > How can you possibly do math operations on a value that is not a number?
>
> DATE, TIME and TIMESTAMP ARE JUST NUMBERS.

First of all, please let that caps lock key alone. :-)
Second, date, time and timestamps may be internally implemented as
numbers (and as a matter of fact they are - just like everything in a
computer), but that's not the point. The set of arithmetic operations
defined on timestamps is separate from that of numbers, and that makes
sense (see below).
From a semantical point of view, a date is NOT a number. I am sorry if I
gave the impression I was talking about internal representation; I
wasn't. I was talking about semantics.

From Vinicius' post in IB-Architect I finally got that he wanted to
obtain a duration (which is a number) by subtracting two timestamps,
which is perfectly legal.

So, Vinicius, just subtract the two dates and you will get a number
representing the difference as a duration expressed in days. You can
refer to page 26 of the Release Notes from InterBase 6 beta docs for all
the possible operation between date/time/timestamps and numeric values.
The key pint here is that you subtract two dates and get, say, 12.5
(twelve days and a half), but trying to treat a *single* date as a
number just doesn't make sense.
I may well be too much nitpicking...

Lester, you may want to have a look at that table too. ;-)

> > What would be the float equivalent of today's noon, for example?
>
> 34000.5 ( I gested the date bit <g> )

This just doesn't make sense unless you are going to perform additions
or subtractions with numbers. And then you will get a timestamp which
may well be represented as 34264.2343, but remains a timestamp.
If you perform those operations with timestamps, instead, you will get
numbers as results.

34000.5 is no more equal to today's noon than 65 is to 'A'.

> UPDATE TABLE SET FIELD1 = 'NOW' + 10 will give you ten days
> time.

No, it will give you a timestamp which is ten days in the future. I hope
you see the difference.

> select FIELD1 from TABLE into :FLOAT
>
> will give you a number but the conversion to text happens
> automatically.

Torturing the figures to have them match the theory? ;-)
Your select will give you a result of the type of TABLE.FIELD1; if it's
a date/time/timestamp you don't see the conversion of it to a string,
just the only reasonable printed representation for it (in no case
should you see 3045.533).

I hope I have made myself clearer and also hope Vinicius has solved his
problem.
Ciao
--
____
_/\/ando