SQL> select to_char(sysdate,'yyyy-mm-dd') from dual;
SQL> select to_char(sysdate,'hh24-mi-ss') from dual;
mysql> select date_format(now(),'%Y-%m-%d');
mysql> select time_format(now(),'%H-%i-%S');
ÈÕÆÚº¯Êý
Ôö¼ÓÒ»¸öÔ£º
SQL> select to_char(add_months(to_date ('20000101','yyyymmdd'),1),'yyyy-mm-dd') from dual;
½á¹û£º2000-02-01
SQL> select to_char(add_months(to_date('20000101','yyyymmdd'),5),'yyyy-mm-dd') from dual;
½á¹û£º2000-06-01
mysql> select date_add('2000-01-01',interval 1 month);
½á¹û£º2000-02-01
mysql> select date_add('2000-01-01',interval 5 month);
½á¹û£º2000-06-01
½ØÈ¡×Ö·û´®£º
SQL> select substr('abcdefg',1,5) from dual;
SQL> select substrb('abcdefg',1,5) from dual;
½á¹û£ºabcdemysql> select substring('abcdefg',2,3);
½á¹û£ºbcd
mysql> select mid('abcdefg',2,3);
½á¹û£ºbcd
mysql> select substring('abcdefg',2);
½á¹û£ºbcdefg
mysql> select substring('abcdefg' from 2);
½á¹û£ºbcdefg
ÁíÓÐSUBSTRING_INDEX(str,delim,count)º¯Êý
·µ»Ø´Ó×Ö·û´®strµÄµÚcount¸ö³öÏֵķָô·ûdelimÖ®ºóµÄ×Ó´®¡£
Èç¹ûcountÊÇÕýÊý£¬·µ»Ø×îºóµÄ·Ö¸ô·ûµ½×ó±ß(´Ó×ó±ßÊý) µÄËùÓÐ×Ö·û¡£
Èç¹ûcountÊǸºÊý£¬·µ»Ø×îºóµÄ·Ö¸ô·ûµ½ÓұߵÄËùÓÐ×Ö·û(´ÓÓÒ±ßÊý)¡£