我试图绕过两个日期,期望一些浮动价值回来。 但我回过来的是:
+000000000 00:00:07.225000
价值86400的倍数(我想在第二段中有所区别)正在得到更加奇怪的回报:
+000000007 05:24:00.000000000
任何想法? 我的怀疑与投放类型有关。
我试图绕过两个日期,期望一些浮动价值回来。 但我回过来的是:
+000000000 00:00:07.225000
价值86400的倍数(我想在第二段中有所区别)正在得到更加奇怪的回报:
+000000007 05:24:00.000000000
任何想法? 我的怀疑与投放类型有关。
页: 1 页: 1
减去时间序列的结果是interval
。 减去<代码>后代码>栏数为两个日期之间的天数。
This is documented in the manual:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements001.htm#i48042
因此,在你迄今为止排出你的时段时,你应当得到你们的期待:
with dates as (
select timestamp 2012-04-27 09:00:00 as col1,
timestamp 2012-04-26 17:35:00 as col2
from dual
)
select col1 - col2 as ts_difference,
cast(col1 as date) - cast(col2 as date) as dt_difference
from dates;
<><><>><>>><>>>>>
If you want to convert the interval so e.g. the number of seconds (as a number), you can do something like this:
with dates as (
select timestamp 2012-04-27 09:00:00.1234 as col1,
timestamp 2012-04-26 17:35:00.5432 as col2
from dual
)
select col1 - col2 as ts_difference,
extract(hour from (col1 - col2)) * 3600 +
extract(minute from (col1 - col2)) * 60 +
(extract(second from (col1 - col2)) * 1000) / 1000 as seconds
from dates;
以上是<代码>55499.5802。
Read this article: http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129
例:
create table yourtable(
date1 date,
date2 date
)
SQL> select datediff( ss , date1, date2 ) seconds from yourtable
SECONDS
----------
6269539
I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...
I ve got the following objects: CREATE FUNCTION CONSTFUNC RETURN INT DETERMINISTIC AS BEGIN RETURN 1; END; CREATE TABLE "FUNCTABLE" ( "ID" NUMBER(*,0) NOT NULL, "VIRT" NUMBER GENERATED ALWAYS AS ...
The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...
I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...
I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...
I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...
I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...
we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...