Here is another way.
select DAY(DATEADD(d,-1,DATEADD(m,DATEDIFF(m,0,GETDATE())+1,0)))
The bennifit is it is just a bit shorter and requires replacing only 1 GETDATE().
Or this which is even shorter
select DAY(DATEADD(m,DATEDIFF(m,0,GETDATE())+1,-1))
-1 represents 12/31/1899 and since the maximum number of days in a month is 31 if less then it will give you the highest value for the month for the date replacing GETDATE().
Edited by - antares686 on 07/14/2003 04:17:29 AM