Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi ,I HAVE TABLE FOR EXAMPLE,emp sal Arrivaldate111 200 03-mar-2011100 200 03-mar-2008150 200 06-mar-2012170 200 03-mar-2003178 200 03-mar-2004112 200 12-jun-2012-------------------->For Example THIS IS TABLE WE HAVE LOT OF RECORDSI need querry to get based on this condition:Arrival Date is between Previous Year First Day Same Month And Current day.
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-06-12 : 11:45:25
If arrivaldate column is of type DATETIME or SMALLDATETIME, then you can use a where clause like this:
WHERE arrivaldate >= DATEADD(month,DATEDIFF(month,0,GETDATE())-12,0) AND arrivaldate < GETDATE()