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
 General SQL Server Forums
 New to SQL Server Programming
 finding ytd and ytd of previous year

Author  Topic 

gavakie
Posting Yak Master

221 Posts

Posted - 2008-06-02 : 17:03:28
if i wanted to say find sales of year where dates are ytd and ytd of the previous year date and year

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-02 : 23:33:38
SELECT * FROM Sales WHERE Year(DateField) =YEAR(GETDATE()) AND MONTH(DateField)<=MONTH(GETDATE() to get current YTD. to get prev year YTD reduce year by 1.
Go to Top of Page
   

- Advertisement -