Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I would like to supply the month and year ... and have it tell me the last day of that month and year.So if I say 04, 2002 ... I want to get back 30Anyone know an easy way to do this.Thanks
robvolk
Most Valuable Yak
15732 Posts
Posted - 2002-04-18 : 19:36:58
CREATE PROCEDURE GetLastDay @month int, @year int ASSELECT CASEWHEN @month IN (1,3,5,7,8,10,12) THEN 31WHEN @month=2 THEN CASE WHEN (@year%400<>0 AND @year%100=0 OR @year%4=0) THEN 28 ELSE 29 ENDELSE 30 END AS LastDay