【ASP】取得年月的最後一天

取得某年某月的最後一天
' Returns the last day of the month. Takes into account leap years
' Usage: LastDay(Month, Year)


Function LastDay(MyMonth, MyYear)
 'MyYear用民國年算法
 'LastDay=day(dateserial(MyYear+1911,MyMonth+1,0))

 'MyYear用西元年算法
  LastDay=day(dateserial(MyYear,MyMonth+1,0))

 '以上紅色字...2擇一 
End Function

Ex:2018年11月的最後一天
Response.Write     LastDay(11,2018)  =>30

Ex:2018年2月的最後一天
Response.Write     LastDay(2,2018)   =>28

留言

這個網誌中的熱門文章

【SQL】新增流水號序號之欄位IDENTITY函式用法

【AJAX】用JQuery寫法實作資料介接JSON

【C#】解決MVC WEB API執行,出現404找不到資源