In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The usage of TRUNC function
The TRUNC function is used to truncate values.
There are two uses: TRUNC (NUMBER) represents the truncation number, and TRUNC (date) represents the truncation date.
(1) truncation figures:
Format: TRUNC (N1 ~ N2), N1 represents the truncated number, N2 indicates the bit to be truncated. N2 can be a negative number, which means before the truncated decimal point. Note that TRUNC truncation is not rounded.
SQL > select TRUNC (15.79) from dual
TRUNC (15.79)
-
fifteen
SQL > select TRUNC (15.79jue 1) from dual
TRUNC (15.79 and 1)
-
15.7
SQL > select trunc (15.79) from dual
TRUNC (15.79 Mai Mui 1)
-
ten
(2) cut-off date:
Execute the command first: alter session set nls_date_format='yyyy-mm-dd hh34:mi:hh'
Intercept today:
SQL > select sysdate,trunc (sysdate,'dd') from dual
SYSDATE TRUNC (SYSDATE,'DD')
--
2009-03-24 21:31:17 2009-03-24 00:00:00
Intercept the first day of the week:
SQL > select sysdate,trunc (sysdate,'d') from dual
SYSDATE TRUNC (SYSDATE,'D')
--
2009-03-24 21:29:32 2009-03-22 00:00:00
Intercept the first day of the month:
SQL > select sysdate,trunc (sysdate,'mm') from dual
SYSDATE TRUNC (SYSDATE,'MM')
--
2009-03-24 21:30:30 2009-03-01 00:00:00
Intercept the first day of this year:
SQL > select sysdate,trunc (sysdate,'y') from dual
SYSDATE TRUNC (SYSDATE,'Y')
--
2009-03-24 21:31:57 2009-01-01 00:00:00
Intercept to the hour:
SQL > select sysdate,trunc (sysdate,'hh') from dual
SYSDATE TRUNC (SYSDATE,'HH')
--
2009-03-24 21:32:59 2009-03-24 21:00:00
Intercept to minutes:
SQL > select sysdate,trunc (sysdate,'mi') from dual
SYSDATE TRUNC (SYSDATE,'MI')
--
2009-03-24 21:33:32 2009-03-24 21:33:00
Get the first day of last month:
SQL > select TRUNC (add_months (SYSDATE,-1), 'MM') 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.