In Oracle, you can use the "to_char()" function to convert the date into seconds. This function can convert the date according to the specified format and output the result as a string. You only need to set the second parameter It can be the required seconds format, and the syntax is "to_char(date,"seconds format")".
The operating environment of this tutorial: Windows 10 system, Oracle version 12c, Dell G3 computer.
to_char()
The syntax is:
to_char(日期,"转换格式" )
Convert the given date according to " Convert format" conversion.
Conversion format:
Indicates year: y represents the last digit of the year yy represents the last 2 digits of the year yyy represents the last 3 digits of the year yyyy represents the year with 4 digits
represents month: mm represents the month with 2 digits; mon represents the abbreviated form such as November or nov; month represents the full name such as November or November
represents day: dd represents the day of the month ; ddd represents the day of the year; dy represents the day of the week in abbreviation such as Friday or fri; day represents the day of the week 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 means minute
Representing second: ss 2 digits represent hexadecimal seconds
Representing quarter: q One digit represents quarter (1-4)
In addition, ww is used to represent the number of the year Week w is used to indicate the week of the month.
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
The example is as follows:
1. Get the current week number of this month
2: Get the day of the week that the current date is. Note that Sunday is the first day
Extended knowledge:
to_date("To convert "String", "Conversion format") The formats of the two parameters must match, otherwise an error will be reported.
That is, the first parameter is interpreted according to the format of the second parameter.
Recommended tutorial: "Oracle Video Tutorial"
The above is the detailed content of How to convert Oracle date to seconds. For more information, please follow other related articles on the PHP Chinese website!