Home  >  Article  >  Database  >  How to set the query date format in oracle

How to set the query date format in oracle

WBOY
WBOYOriginal
2022-06-10 11:07:225577browse

In Oracle, you can use the "to_char()" function in conjunction with the select statement to set the date format of the query. The select statement is used to query data, and the "to_char()" function is used to set the date format. The syntax is: "select to_char(date data column,'date format') from ...".

How to set the query date format in oracle

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

How to set the query date format in Oracle

Use the to_char() function to set the query date format.

The syntax is:

to_char(日期,"转换格式" )

Examples are as follows:

Original format:

select Starttime,Endtime from ELEARNING.Opt_Training where Orgid = '6c457da0-7825-4df7-bcd7-0e0e9c37631b';

Query results:

How to set the query date format in oracle

Query format: to_char() function, return yyyy/MM/dd:

select to_char(Starttime,'yyyy/MM/dd'),to_char(Endtime,'yyyy/MM/dd') from ELEARNING.Opt_Training where Orgid = '6c457da0-7825-4df7-bcd7-0e0e9c37631b';

Query results:

How to set the query date format in oracle

Recommended tutorial: "Oracle Video Tutorial"

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

Statement:
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