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.
| Author |
Topic |
|
u2p_inst
Yak Posting Veteran
78 Posts |
Posted - 2004-04-21 : 10:59:41
|
| i have query like Declare @Month as datetimeSet @Month='02/29/2004'selectdateadd(month,1,@Month)The result is 2004-03-29, in the case i need get the max/min day in that monthis it possible so the result like 2004-03-31oh |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2004-04-21 : 11:11:22
|
Well the min is always "1"...!!! as for the max.....determine the 1st of the next month, and subtract 1 day from it! |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2004-04-21 : 12:11:14
|
| --First Day of Monthselect DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)--Last Day of Monthselect dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate() )+1, 0)) |
 |
|
|
|
|
|