On Dec 12, 10:19 am, Hemant Shah <s...@typhoon.xnet.comwrote:
Folks,
How can I convert date/time/timestamp to an integer?
According to UDB 8.1 docs that I have,
INTEGER('1964-07-20') should return 19640720, but when I run the SQL
statement I get different answer:
# db2 "VALUES INTEGER(CHAR(1964-07-20))"
1
-----------
1937
1 record(s) selected.
How can I convert CURRENT TIMESTAMP to a integer?
# db2 "VALUES INTEGER(CHAR(CURRENT TIMESTAMP))"
1
-----------
SQL0420N Invalid character found in a character string argument of the
function "INTEGER". SQLSTATE=22018
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMails...@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
There is a function called DAYS(expression) that does something
similar to what you want.
DAYS scalar function
>>-DAYS--(--expression--)--------------------------------------><
The schema is SYSIBM.
The DAYS function returns an integer representation of a date.
The argument must be a date, timestamp, or a valid character string
representation of a date or timestamp that is neither a CLOB nor a
LONG VARCHAR. In a Unicode database, if a supplied argument is a
graphic string, it is first converted to a character string before the
function is executed.
The result of the function is a large integer. If the argument can be
null, the result can be null; if the argument is null, the result is
the null value.
The result is 1 more than the number of days from January 1, 0001 to
D, where D is the date that would occur if the DATE function were
applied to the argument.