Home > Database > Oracle > body text

What are the Oracle query time statements?

coldplay.xixi
Release: 2020-07-16 13:42:56
Original
8148 people have browsed it

Oracle query time statements include: 1. Query the year of the time, the code is [select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')]; 2. Query the month of the time, the code It is [select to_char(sysdate,'mm')].

What are the Oracle query time statements?

Oracle query time statements include:

Convert date to string

select to_char(sysdate,’yyyy-mm-dd hh24:mi:ss’) as nowTime from dual;
Copy after login

Get time Year

select to_char(sysdate,’yyyy’) as nowYear from dual;
Copy after login

Get the month of the time

select to_char(sysdate,’mm’) as nowMonth from dual;
Copy after login

Get the day of the time

select to_char(sysdate,’dd’) as nowDay from dual;
Copy after login

Get the hour of the time

select to_char(sysdate,’hh24′) as nowHour from dual;
Copy after login

Get the minute of the time

select to_char(sysdate,’mi’) as nowMinute from dual;
Copy after login

Get the seconds of time

select to_char(sysdate,’ss’) as nowSecond from dual;
Copy after login

oracle date format

to_date("String to be converted","Converted format" ) The formats of the two parameters must match, otherwise an error will be reported. That is, the first parameter is interpreted in the format of the second parameter.

to_char(Date,"Conversion Format") That is, convert the given date according to the "Conversion Format".

Conversion format:

  • Represents year: y represents the last digit of the year yy represents the last two digits of the year yyy represents the year The last three digits yyyy use 4 digits to represent the year

  • represents month: mm uses 2 digits to represent the month; mon uses an abbreviated form such as November or nov; month uses the full name such as November Or november

  • means day: dd means the day of the month; ddd means the day of the year; dy means the day of the week, such as Friday or fri; day means the day of the week. Write it in full, such as Friday or Friday.

  • means hour: hh 2 digits means hour in hexadecimal; hh24 2 digits means hour 24 hours

  • means minute: mi 2 digits represents the minute

  • represents the second: ss 2 digits represents the second in hexadecimal

  • represents the quarter: q One ​​digit The number represents the quarter (1-4)

. In addition, ww is used to represent the week of the year; w is used to represent the week of the month. weeks.

Time range under 24-hour format: 00:00:00-23:59:59

Time range under 12-hour format: 1:00:00-12:59:59

For example:

select to_char(sysdate,’yy-mm-dd hh24:mi:ss’) from dual //显示:08-11-07 13:22:42
select to_date(‘2005-12-25,13:25:59′,’yyyy-mm-dd,hh24:mi:ss’) from dual //显示:2005-12-25 13:25:59
Copy after login

Related learning recommendations: oracle database learning tutorial

The above is the detailed content of What are the Oracle query time statements?. 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