system date/time
Posted in 2004
Topics: General Discussion
How would I select just the system date/time from an Informix datebase. For example, in Oracle it would be "select sysdate from dual". I just need the Informix equivalent. TIA
kstahl wrote:
> How would I select just the system date/time from an Informix datebase.
>
> For example, in Oracle it would be "select sysdate from dual". I just
> need the Informix equivalent.
The standard Informix idiom is:
SELECT TODAY FROM Systables WHERE Tabid = 1;
Alternatives include:
CREATE TABLE Dual
(
Number INTEGER NOT NULL CHECK(Number = 0) PRIMARY KEY
);
INSERT INTO Dual VALUES(0);
REVOKE ALL ON Dual FROM PUBLIC;
GRANT SELECT ON Dual TO PUBLIC;
SELECT TODAY FROM Dual;
If you want time as well as date, then:
SELECT CURENT FROM Dual;
And so the list goes on...
SELECT ... FROM "informix".Systables WHERE Tabid = 1
works because there is only one entry in systables with tabid = 1, and
that's the entry for systables. If that goes missing, you've got
bigger problems than that your select doesn't work any more.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
Jonathan Leffler wrote:
[...]
> If you want time as well as date, then:
>
> SELECT CURENT FROM Dual;
Oops - typo: CURRENT -- optionally qualified by something like YEAR TO
FRACTION(3), or MONTH TO MINUTE, or ...
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/