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 |
|
kendwigans
Starting Member
1 Post |
Posted - 2010-09-10 : 09:47:05
|
| I need the sql code which will return just those records before the current month. Any help is appreciated |
|
|
rohitvishwakarma
Posting Yak Master
232 Posts |
Posted - 2010-09-10 : 10:17:57
|
| Hi,DATEPART(mm, GETDATE()) -1 will give you the previous month. similarly you can use dd and yyyy in place of mm for Date and Year respectively.Use in the query like this SELECT .,.,... FROM tblXYZ WHERE DATEPART(mm, your_date_column) = DATEPART(mm, GETDATE()) - 1 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-13 : 05:47:45
|
| where date_col<dateadd(month,datediff(month,0,getdate()),0)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|