Three database date conversions comparison:
http://blog.csdn.net/zljjava/article/details/17552741
SQL type conversion function: Cast (type1 as Type2)
Date types in the database SQL SERVER
DATE 1970-01-01
DATETIME 1970-01-01 00:00:00
Oracle
DATE 2015-08-07 17:34:37
TIMESTAMP 1970-01-01 00:00:00.000000 is the extended type of date, with fractional seconds
Date-to-string Oracle
To_char (sysdate, ' yyyy-mm-dd ')
Select To_char (sysdate, ' Yyyy-mm-dd hh24:mi:ss ') as nowtime from dual;
SQL Server
CONVERT (varchar, cast (' 1970-01-01 ' as DateTime), 120) 1970-01-01 00:00:00
select convert(char(7),getdate(),20);--2015-10
SELECT CAST( DATEPART(yyyy,getdate()) as CHAR(4)) + cast( DATEPART(mm,getdate()) as char(2));-- 201510
SelectCONVERT(varchar(100), GETDATE(), 23) --2006-05-16
Http://www.cnblogs.com/zhangq723/archive/2011/02/16/1956152.html
Mysql
Date_format (Sysdate (), '%y-%m-%d ');
String to date Oracle
To_date (sysdate, ' yyyy-mm-dd ')
Select To_timestamp (' 2012-5-13 18:45:34:567 ', ' yyyy-mm-dd hh24:mi:ss:ff9 ') +0 from dual;
Mysql
STR_TO_DATE(sysdate(),‘%Y-%m-%d‘);
Number to string Oracle
(1) using the TO_CHAR function to process numbers
To_char (number, ' format ')
To_char (Salary, ' $99,999.99 ');
(2) using the TO_CHAR function to process the date
To_char (date, ' format ');
To_char (sysdate, ' Q ') season
To_char (sysdate, ' yyyy ') year
To_char (sysdate, ' mm ') month
To_char (sysdate, ' DD ') day
To_char (sysdate, ' d ') Day of the week
To_char (sysdate, ' Day ') days of the week
To_char (sysdate, ' DDD ') the first day of the year
Three database date-to-string comparisons with SQL Server, Oracle, MySQL (V4.11)