使用資料庫SQL語句獲得當前月的天數

2021-04-25 06:32:38 字數 452 閱讀 4687

view plain

copy to clipboard

print?

--獲得當月天數  

select day(dateadd(mm,1,getdate())-day(getdate())) as 本月天數 ;  

select getdate() as 當前日期;  

select day(getdate()) as 目前第幾天;  

select getdate()-day(getdate())  as 上個月最後一天; -- 減去了當前的天數  

select dateadd(mm,1,getdate())-day(getdate()) as 加上乙個月; -- 也就是這個月的最後一天  

select day(dateadd(mm,1,getdate())-day(getdate())) as 獲得當月天數;  

執行效果

使用sql語句獲得當前月天數

使用sql語句獲得當前月天數 獲得當月天數 select day dateadd mm,1,getdate day getdate as 本月天數 select getdate as 當前日期 select day getdate as 目前第幾天 select getdate day getdat...

資料庫獲得當前時間getdate

convert nvarchar 10 count time,121 convert為日期轉換函式,一般就是在時間型別 datetime,smalldatetime 與字串型別 nchar,nvarchar,char,varchar 相互轉換的時候才用到的函式的3個引數,第1個引數為,轉換後的大小,...

資料庫SQL語句使用

擷取字段 string sgtoday,6,2 引數1 要擷取的字段,引數2 從第幾位擷取,引數3 擷取長度。例如 擷取folder no欄位從第一位開始的長度和fonds no相同的字段 select from folder description kj where substring folde...