1、Ms Sql Server
SELECT getdate(); SELECT getdate()-90 ; -- 取90天前日期; select convert(varchar,getdate()-90,23); --转换为字符串,只取日期 SELECT year(getdate()); SELECT month(getdate()); SELECT day(getdate()); 执行结果: 1 2022-07-27 08:52:32.383 2 2022-04-28 08:52:32.383 3 2022-04-28 4 2022 5 7 6 27
2 ORACLE
select to_char(销售日期,'yyyy') as year,--年; select to_char(销售日期,'mm') as month--月; select sysdate -30;
select null from dual where 1=2
3 MYSQL