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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Need sql querry for critical logic

Author  Topic 

aniletc37
Starting Member

4 Posts

Posted - 2012-06-12 : 10:25:02
Hi ,

I HAVE TABLE FOR EXAMPLE,

emp sal Arrivaldate
111 200 03-mar-2011
100 200 03-mar-2008
150 200 06-mar-2012
170 200 03-mar-2003
178 200 03-mar-2004
112 200 12-jun-2012-------------------->For Example THIS IS TABLE WE HAVE LOT OF RECORDS

I 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()
Go to Top of Page
   

- Advertisement -