Home > Database > Oracle > body text

How to query the data of the day in oracle

WBOY
Release: 2022-05-24 16:56:36
Original
13358 people have browsed it

In Oracle, you can use the trunc function to query the data of the day. This function can be used to intercept time or numerical values. Use this function with the select statement to query the data of the day. The syntax is "select*from. ..where trunc(...)=trunc(sysdate)”.

How to query the data of the day in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to query the data of the day in oracle

The syntax example is as follows:

select * from T_BASE where trunc(BASE_TIME)=trunc(sysdate)
Copy after login

TRUNC function description:

Used to intercept time or value and return the specified value.

Syntax

(1) Date processing:

    TRUNC(date,[fmt])
Copy after login

Date is a necessary parameter, which is an input date value

The fmt parameter can be ignored, yes Date format, by default it represents 0 o'clock on the specified date.

(2) Numerical processing:

    TRUNC(number,[decimals])
Copy after login

Number is a necessary parameter, which is a number value entered

The decimals parameter can be ignored, it is the number of digits to be intercepted, the default means truncating the value after the decimal point.

Examples are as follows:

How to query the data of the day in oracle

Expand knowledge:

Processing numerical values:

--123.56,将小数点右边指定位数后面的截去; 
select trunc(123.567,2) from dual;
--100,第二个参数可以为负数,表示将小数点左边指定位数后面的部分截去,即均以0记;
select trunc(123.567,-2) from dual;
--123,默认截去小数点后面的部分;
select trunc(123.567) from dual;
Copy after login

Recommended tutorial:《 Oracle Video Tutorial

The above is the detailed content of How to query the data of the day in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template