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 |
|
pras2007
Posting Yak Master
216 Posts |
Posted - 2009-09-28 : 00:13:46
|
| Hello All,I want to know how I can query the first day of any given month and the last day of any given month… Below is a script that I think gives me the first of any given month.select dateadd(month,datediff(month,0,getdate())-1,0)Result: 2009-08-01 00:00:00.000Does anybody know what script will provide the last day of any given month?Please advice.Thank |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-28 : 00:22:33
|
select first_curr_month = dateadd(month, datediff(month, 0, getdate()), 0), last_curr_month = dateadd(month, datediff(month, 0, getdate()) + 1, -1) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|