In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Oracle gets the current date and date format
Get system date: SYSDATE ()
Format date: TO_CHAR (SYSDATE (), 'YY/MM/DD HH24:MI:SS)
Or TO_DATE (SYSDATE (), 'YY/MM/DD HH24:MI:SS)
Formatted numbers: TO_NUMBER
Note: TO_CHAR converts dates or numbers to strings
TO_CHAR (number, 'format')
TO_CHAR (salary,'$99999.99')
TO_CHAR (date, 'format')
TO_DATE converts a string to a date type in the database
TO_DATE (char, 'format')
TO_NUMBER converts strings to numbers
TO_NUMBER (char, 'format')
Returns the system date and outputs 25-12-09
Select sysdate from dual
Mi is minutes, output 2009-12-25 14:23:31
Select to_char (sysdate,'yyyy-MM-dd HH24:mi:ss') from dual
Mm will show the month and output 2009-12-25 14:12:31
Select to_char (sysdate,'yyyy-MM-dd HH24:mm:ss') from dual
Output 09-12-25 14:23:31
Select to_char (sysdate,'yy-mm-dd hh34:mi:ss') from dual
Output 2009-12-25 14:23:31
Select to_date ('2009-12-25 14-14-23-15-31-12-12-25 14-14-23-15-31-12-12-25 14-14-14-23-15-31-12-12-25 14-14-14-23-15-31-12-25 14-14-14-23-15-31-12-25 14-14-14-23-12-25-12-25 14-14-23-12-25 14-14-23-12-25-12-25 14-14-23-12-25 14-14-23-12-25-12-25 14-14-23-12-25 14-14-23-12-25 14-14-23-12-25 14-14-23-12-25 14-14-24-12-25 14-14-24-24-12-25
And if you write in the above form:
Select to_date ('2009-12-25 14-14-23-13-31-12-12-25 14-14-23-31-12-12-25 14-14-23-15-31-12-12-25 14-14-23-15-31-12-25 14-14-14-23-15-31-12-25 14-14-23-12-25 14-14-23-12-25-12-25 14-14-23-12-25-12-25 14-14-23-12-25 14-14-23-12-25 14-14-23-12-25-12-25 14-14-23-12-25 14-14-23-12-25-12-25 14-14-23-12-25 14-14-23-12-25 14-14-23-12-25 15-12-25 14
An error will be reported because the hourly hh is 12-ary, 14 is illegal input and cannot be matched.
Output $100.0000.00:
Select to_char (1000000, 999, 9999) from dual
Output RMB10,000,00:
Select to_char (1000000 people, 999, 999, 999) from dual
Output 1000000.12:
Select trunc (to_number ('1000000.123'), 2) from dual
Select to_number ('1000000.123') from dual
Converted format:
The: y for year represents the last bit of the year,
Yy represents the last two digits of the year,
Yyy represents the last three digits of the year,
Yyyy represents the year in four digits
For month: mm represents the month with 2 digits,
Mon is in abbreviated form, such as November or nov,
Month uses its full name, such as November or november
For day: dd indicates the day of the month,
Ddd said that the day of the year,
The day of the week in dy, abbreviated as Friday or fri,
Day the day of the week, the full name, such as Friday or friday
For hour: hh 2 digits represent hourly 12-digit,
Hh34 2 digits represent 24 hours.
For minute: mi 2 digits represent minutes
For second: ss 2 digits denote base 60 seconds
Q-digit indicates quarter (1-4)
In addition, ww is used to indicate the week of the year and the week of the month.
Time range under the 24-hour system: 00:00:00-23:59:59
Time range under the 12-hour system: 1:00:00-12:59:59
Number format: 9 represents a number
0 force display 0
$place a $symbol
L place a floating local currency character
. Show decimal point
To display a thousand-bit indicator
Add:
Current time minus 7 minutes
Select sysdate,sysdate-interval'7' MINUTE from dual
Current time minus 7 hours of time
Select sysdate-interval'7' hour from dual
Current time minus 7 days
Select sysdate-interval'7' day from dual
Current time minus July time
Select sysdate,sysdate-interval'7' month from dual
Current time minus 7 years
Select sysdate,sysdate-interval'7' year from dual
Time interval multiplied by a number
Select sysdate,sysdate-8*interval'7' hour from dual
Note:
Dual is an actual table in Oracle that can be read by any user and is often used in select statements that do not have a target table.
Different systems may return dates in different formats.
Returns the currently connected user: select user from dual
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.