(012) Daily SQL Learning: To_char (Date,format)

Source: Internet
Author: User

Sysdate 2009-6-16 15:25:10  
TRUNC (Sysdate) 2009-6-16  
To_char (sysdate, ' YYYYMMDD ') 20090616 to Japan
To_char (sysdate, ' YYYYMMDD HH24:MI:SS ') 20090616 15:25:10 to seconds
To_char (Systimestamp, ' YYYYMMDD HH24:MI:SS. FF3 ') 20090616 15:25:10.848 to milliseconds
To_char (sysdate, ' AD ') Ad  
To_char (sysdate, ' AM ') Afternoon  
To_char (sysdate, ' BC ') Ad  
To_char (sysdate, ' CC ') 21st  
To_char (sysdate, ' D ') 3 The day of the foreigner
To_char (sysdate, ' Day ') Tuesday Day of the Week
To_char (sysdate, ' DD ') 16  
To_char (sysdate, ' DDD ') 167  
To_char (sysdate, ' DL ') June 16, 2009 Tuesday  
To_char (sysdate, ' DS ') 2009-06-16  
To_char (sysdate, ' DY ') Tuesday  
To_char (Systimestamp, ' SS. FF3 ') 10.848 Milliseconds
To_char (sysdate, ' FM ')    
To_char (sysdate, ' FX ')    
To_char (sysdate, ' HH ') 03  
To_char (sysdate, ' HH24 ') 15  
To_char (sysdate, ' IW ') 25 The first few weeks
To_char (sysdate, ' iyy ') 009  
To_char (sysdate, ' IY ') 09  
To_char (sysdate, ' J ') 2454999  
To_char (sysdate, ' MI ') 25  
To_char (sysdate, ' MM ') 06  
To_char (sysdate, ' MON ') June  
To_char (sysdate, ' MONTH ') June  
To_char (Systimestamp, ' PM ') Afternoon  
To_char (sysdate, ' Q ') 2 First quarter
To_char (sysdate, ' RM ') VI  
To_char (sysdate, ' RR ') 09  
To_char (sysdate, ' RRRR ') 2009  
To_char (sysdate, ' SS ') 10  
To_char (sysdate, ' sssss ') 55510  
To_char (sysdate, ' TS ') 3:25:10  
To_char (sysdate, ' WW ') 24  
To_char (Systimestamp, ' W ') 3  
To_char (Sysdate, ' year ') Thousand NINE  
To_char (sysdate, ' YYYY ') 2009  
To_char (Systimestamp, ' YYY ') 009  
To_char (Systimestamp, ' YY ') 09  

Transfer from: http://blog.csdn.net/suncrafted/article/details/4273528

SelectTrunc (Sysdate,'yy') fromDual;--first day of the yearSelectTrunc (Sysdate,'mm') fromDual--first day of the monthSelectTrunc (Sysdate,' Day')+1  fromDual--first day of the week
--How many weeks are there in a year? withX0 as (SelectTo_date ('2018-01-01','YYYY-MM-DD') asEarly fromdual), X1 as (SelectAt the beginning of the year, Add_months (early A) asAt the beginning of next year fromx0), X2 as (SelectEarly next year, early next year-Early asDays fromx1), X3 as (SelectEarly+ Level-1  asDate fromX2 Connect by  Level <=days), X4 as (SelectDate, To_char (date,' Day') asWeek fromX3)SELECTWeekCount(*) fromX4Group  byWeek

(012) Daily SQL Learning: To_char (Date,format)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.