728x90
Problem(Abstract)
This article shows several methods of producing values in minutes from the difference of two datetime values. These examples can also be applied to produce hours and seconds.
Resolving the problem
Q. How can I determine the number of hours, minutes or seconds difference between two datetime values?
A. This can be accomplished with SQL using the following methods:
- create temp table tmp_dt_tab
(
col1 datetime year to second,
col2 datetime year to second,
col3 interval minute(9) to minute
) with no log;
- insert into tmp_dt_tab values (CURRENT YEAR TO SECOND, "2001-09-11 12:00:00", NULL);
- update tmp_dt_tab set col3 = (col1 - col2);
- select interval(0) minute(9) to minute +
(current year to minute - "2001-09-11 12:00")
from systables
where tabid = 99;
- select (current year to minute -
"2001-09-11 12:00")::interval minute(9) to minute
from systables
where tabid = 99;
- select cast ((current year to minute - "2001-09-11 12:00") as
interval minute(9) to minute)
from systables
where tabid = 99;
http://www-01.ibm.com/support/docview.wss?uid=swg21216971
728x90
'Informix > informix reference' 카테고리의 다른 글
Understanding on Smart blob space. (0) | 2014.06.12 |
---|---|
Dummy updates (0) | 2014.06.02 |
How to retrieve IBM Informix Server Configuration File settings from sysmaster (0) | 2014.04.24 |
How to get version of Informix JDBC Driver (0) | 2014.03.07 |
SQL to find list of the tables in a particular chunk (0) | 2014.03.06 |