February 20, 2003 at 4:06 am
Hi Guys!
can you help me...
1) what would be the condition if i want to get all transactions dates last year except this year?
2) what would be the condition if i want to get all transaction dates last year but the same period this year?
a comparison of this year Jan 2003 transaction versus the transaction last Jan 2002 ...
Thanks
lhavn
February 20, 2003 at 7:59 am
This should get you started:
DECLARE @Year INT
DECLARE @Month TINYINT
SET @Year = 2003
SET @Month = 1
SELECT * FROM TransTable
WHERE DatePart(yy, TransDate) = @Year
AND DatePart(mm, TransDate) = @Month
SELECT * FROM TransTable
WHERE DatePart(yy, TransDate) = @Year - 1
AND DatePart(mm, TransDate) = @Month
February 20, 2003 at 6:00 pm
Jpipes,
would it be possible without "Declare Statemet"
February 20, 2003 at 10:30 pm
Jpipes,
thanks!
i've done using the declare statement ...
one more thing ...
i try to declare MonthFrom and MonthTo to show the whole year last year ... but the result is zero (0) ...
can't do it ...
any idea?
thanks
lhavn
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply