Home  >  Article  >  Database  >  How to query the month in oracle

How to query the month in oracle

WBOY
WBOYOriginal
2022-02-28 14:42:5712654browse

In Oracle, you can use the "to_char()" function and the "mm" keyword to query the month. The "to_char()" function is a string conversion function, and the syntax is "where to_number(to_char(table Date field,'mm'))=the month to be found".

How to query the month in oracle

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

How to query the month in oracle

to_char() is Oracle’s character conversion function. to_char(value,'format') value is the value to be converted, and 'format' is the converted pattern.

The style fm9900.0099 here includes the following meanings:

The output string occupies a total of 9 digits, 4 digits before the decimal point and 4 digits after the decimal point.

9 represents the meaning. If the position is a number, the number will be displayed. Otherwise, a space will be used to replace the placeholder. In short, this position must be occupied.

0 represents the meaning. If the position is a number, the number will be displayed. Otherwise, 0 will be used instead of the placeholder. In short, this position must be occupied.

The syntax is:

SELECT * FROM [表名] 
      where  to_number(to_char([表中日期字段],'mm')) = [要查找的月份]

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to query the month 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