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 |
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2009-01-09 : 06:18:15
|
| Hi guys,How can know the ending day of the given month.for exampleselect getdate() as currentdate, '---', ' ' as EndingDaythe result should be : 2009-01-09 16:45:08.090 --- 31 RegardsJs.Reddy |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-09 : 06:23:29
|
| [code]select dateadd(mm,datediff(mm,0,getdate())+1,0)-1[/code] |
 |
|
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2009-01-09 : 06:37:06
|
Thank You Visakh16 quote: Originally posted by visakh16
select dateadd(mm,datediff(mm,0,getdate())+1,0)-1
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-09 : 06:40:25
|
| welcome |
 |
|
|
Skorch
Constraint Violating Yak Guru
300 Posts |
Posted - 2009-01-09 : 12:50:17
|
| This may be just a tiny bit simpler:SELECT DATEADD(mm,DATEDIFF(mm,-1,GETDATE()),-1) |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-09 : 23:07:38
|
| SELECT DATEADD(d, -DAY(DATEADD(m,1,GETDATE())),DATEADD(m,1,GETDATE())) AS 'Last day of the month' |
 |
|
|
|
|
|
|
|