oracle to_char 日期转换字符串(Oracle to_char日期转换字符串)oracle to_char 日期转换字符串(Oracle to_char日期转换字符串)
1 is shown in 12 hours system
SQL>select to_char (sysdate,'YYYY-MM-DD HH12:MI:SS AM') from dual;
TO_CHAR (SYSDATE,'YYYY-MM-DDHH1)
The
2007-06-29 02:50:06 .
2 is shown in 24 hours system
SQL> select to_char (sysdate,'YYYY-MM-DD HH24:MI:SS AM') from dual;
TO_CHAR (SYSDATE,'YYYY-MM-DDHH2)
The
2007-06-29 15:00:58 .
3 gets the first minute of the current time
Select to_char (Sysdate-1/21/60,'HH24:MI:SS') from dual;
TO_CHAR (SYSDATE-1/21/60,'HH24:)
The
15:00:54
4 gets the second minute of the current time
Select to_char (Sysdate+1/21/60,'HH24:MI:SS') from dual;
TO_CHAR (SYSDATE+1/21/60,'HH24:)
The
15:03:53
5 gets one hour before the current time
Select to_char (Sysdate-1/24,'HH24:MI:SS') from dual;
TO_CHAR (SYSDATE-1/24,'HH24:MI:)
The
14:03:13
6 gets one hour after the current time
Select to_char (Sysdate+1/24,'HH24:MI:SS') from dual;
TO_CHAR (SYSDATE+1/24,'HH24:MI:)
The
16:03:32
7 gets the day after the current time
Select to_char (Sysdate+1,'YYYY-MM-DD') from dual;
TO_CHAR (SYSDATE+1,'YYYY-MM-DD')
The
Query the first six months of the current time
Select add_months (sysdate, -6) from dual
1, conversion function
The most important thing to do with the date operation is the two transformation function: to_date (), to_char ()
To_date () acts to convert character types into a date type in a certain format:
Specific uses: to_date ('2004-11-27','yyyy-mm-dd'), the former is a string, the latter is the format of the conversion date, pay attention to, before and after the two should be a correspondence.
For example, to_date ('2004-11-27 13:34:43','yyyy-mm-dd hh24:mi:ss') will get the specific time
Multiple date formats:
YYYY: four bit representation of the year
YYY, YY, Y: the last three, two or one of the year, the default is the current century
The month number of MM:01~12
MONTH: the month represented by nine characters, and the right is filled with blanks
MON: Monthly abbreviati
oracle to char 日期转换字符串(Oracle to char日期转换字符串) 来自淘豆网m.daumloan.com转载请标明出处.