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 |
|
dsscholar
Starting Member
6 Posts |
Posted - 2011-09-22 : 23:44:03
|
| Hi all,Please help with sql in finding first and last day of the previous month. And does year(datecolumn) and month(datecolumn) give year and month part from a date column?Thanks in advance. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-09-23 : 00:10:39
|
[code]declare @date datetimeselect @date = getdate()select [first day of prev month] = dateadd(month, datediff(month, 0, @date) - 1, 0), [last day of prev month] = dateadd(month, datediff(month, 0, @date), -1)[/code]quote: does year(datecolumn) and month(datecolumn) give year and month part from a date column?
Yes KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|