English 中文(简体)
英文字母缩略语
原标题:Extract time part from TimeStamp column in ORACLE
  • 时间:2010-06-01 17:20:16
  •  标签:
  • sql
  • oracle

目前,使用<代码>MytimeStamp Field-TRUNC(MytimeStamp Field)从Oracle的一个时间段提取时间段。

SELECT CURRENT_TIMESTAMP-TRUNC(CURRENT_TIMESTAMP) FROM DUAL

回返

+00 13:12:07.100729

这对我来说,是为了把时间部分从时间规划领域抽出,但我不禁要问,是否有更好的办法(可能利用ORACLE的内在功能)这样做?

最佳回答

http://docs.oracle.com/cd/B19306_01/server.102/b14200/Functions050.htm rel=“nofollow noreferer”>EXTRACT(职能?

问题回答

你们总是能够做这样的事情:

select TO_DATE(TO_CHAR(SYSDATE, hh24:mi:ss ), hh24:mi:ss ) from dual

我认为,这将与时俱进。

你们只想利用时间

to_char(cast(SYSDATE as date), DD-MM-YYYY )

如果你想要时间,就使用时间

to_char(cast(SYSDATE as date), hh24:mi:ss )

参数正在使所有变化成为可能。

 DD-MM-YYYY 

以及

 hh24:mi:ss 

这可能有助于:

Select EXTRACT(HOUR FROM (SYSDATE - trunc(sysdate)) DAY TO SECOND ) From dual;
select TO_DATE(TO_CHAR(SYSDATE, hh24:mi:ss ), hh24:mi:ss ) from dual

这使办公时间少于实际时间。

也许不是这样说的,而是为我工作。

SELECT TRUNC(CURRENT_TIMESTAMP) + (CURRENT_TIMESTAMP - TRUNC(CURRENT_TIMESTAMP)) - TRUNC(CURRENT_TIMESTAMP) FROM dual
-----------------
0,851863425925926

如果没有最后的减员,你将技术、科学和技术部改为时日,即:

SELECT TRUNC(CURRENT_TIMESTAMP) + (CURRENT_TIMESTAMP - TRUNC(CURRENT_TIMESTAMP)) FROM dual
-----------------
20.04.2023 20:31:02
select hour(CURRENT_TIMESTAMP)




相关问题
Export tables from SQL Server to be imported to Oracle 10g

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/...

Connecting to Oracle 10g with ODBC from Excel VBA

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 ...

How to make a one to one left outer join?

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, ...

Insert if not exists Oracle

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 ...

How can I store NULLs in NOT NULL field?

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 ...

Type reference scope

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 ...

OracleParameter and DBNull.Value

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 ...

热门标签