Source: http://www.2cto.com/database/201208/145611.html Today, just take the month and the number of days, if 0 in front of the month to get rid of 0. For example, 2010-01-08, the required result is 1-8. Leads to a series of SQL statements first: using To_number function conversion Auto-intercept 0 Select To_number (to_char (sysdate, ' mm ')) | | ' -' | | To_number (To_char (sysdate, ' DD ')) from dual; Second: Remove 0 Select LTrim (to_char (sysdate, ' mm '), ' 0 ') by using the LTrim function plus fixed parameters | | -' | | LTrim (To_char (sysdate, ' DD '), ' 0 ') from dual; The above two methods achieve what we need, the common feature is to use two functions, but there is no easier way? I guess someone must have thought that Oracle has a format like this. Select To_char (sysdate, ' m-d ') from dual; Unfortunately, the prompt is incorrect and the date format does not exist. Don't lose heart, we continue ...
Third: Use the features of the function. We know select sysdate from dual; The resulting value is: 2010-1-8 11:06:18 that there is no function directly obtained to the month 1 and Day 8, www.2cto.com Our guess is correct, there is indeed such a function, the following function appears, select Extract (month from sysdate) | | ' -' | | Extract (day from sysdate) month from dual; Note: Extract the specific use of ' Google ' bar, will not let you down. A step closer, satisfied, not satisfied, and below. The above method has a common feature, that is, the month and day are separate to take, how to merge together, so much good ah! See our Fourth method: fourth: Skillfully with Oracle's own format select To_char (sysdate, ' Fmmm-dd ') from Dual; ps:the Format_mask Parameter begins with "FM". This means, zeros and blanks are suppressed