一、mysql基本时间格式之间的转换
SELECT DATE_FORMAT(now(),'%Y-%m-%d') as sdtime1 ,
DATE_FORMAT(now(),'%Y-%m-%d %H:%m:%s') as sdtime2
,UNIX_TIMESTAMP(now()) unixtime ,
FROM_UNIXTIME(UNIX_TIMESTAMP(now()),'%Y-%m-%d' ) timetcg,
DATEDIFF(now(),'2017-03-25') as days ,
DATE_ADD(now(),INTERVAL 8 day) as addday ,
DATE_ADD(now(),INTERVAL 8 month) as addday,
DATE_sub(now(),INTERVAL 8 day) as subday
二、sqlserver基本时间格式的转化
select CONVERT(data_type(length),data_to_be_converted,style)
select CONVERT(VARCHAR(10),GETDATE(),120) >>>2017-07-31 最常用的格式
SELECT CONVERT(FLOAT ,'12.58') +10 >>> 22.58
SELECT cast('2014-10-11' as char(10)) >>>2014-10-11 # 把数字转化成文本
----------------------------------------------------
网友评论