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 |
|
dz0001
Starting Member
35 Posts |
Posted - 2012-05-18 : 15:36:28
|
| Hi There,wondering if you can point me the right direction on 1. Current MTD (current month to date)2. Previous MTD (previous month to date)Many thanks |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-05-18 : 15:45:18
|
| SELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0) AS MTDSELECT DATEADD(month, DATEDIFF(month, 0, GETDATE())-1, 0) AS PrevMTD |
 |
|
|
dz0001
Starting Member
35 Posts |
Posted - 2012-05-18 : 16:45:15
|
| robvolk,Thanks for the script, but it seems returing first day of curent month and previous month. I am looking for previous MTD, for example, today is May 21, so previous MTD is April 21, is this possible? |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-05-18 : 16:48:20
|
Whooops:SELECT DATEADD(month, -1, GETDATE()) |
 |
|
|
|
|
|
|
|