SQL Server日期函數,sqlserver日期

來源:互聯網
上載者:User

SQL Server日期函數,sqlserver日期

當前系統日期、時間

select getdate() 

2015-06-18 14:52:27.123
提取日期中的資料

day(), month(),year() 

select getdate(); – 2015-06-18 14:52:27.123
select YEAR(getdate()); – 2015
select MONTH(getdate()); – 6
select day(getdate()); – 18

日期格式轉換
CONVERT

SELECT CONVERT(char(19), getdate(), 120)

輸出格式:2008-02-27
具體參考:MSDN

日期加減運算
select getdate(); — 2015-06-18 15:07:07.770
select dateadd(year,-1,getdate()); — 2014-06-18 15:07:07.787
運算子和運算式

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.