March 15, 2002 at 4:05 pm
hello
i need to know how i can calculated number of days elapsed between two dates on a TSQL statement to use on the following pivot query :
SELECT nome,
SUM(CASE when datalc-getdate()<30 then deb ELSE 0 END) AS 30days,
SUM(CASE when datalc-getdate()>30 or <60 THEN deb ELSE 0 END) AS 60days,
FROM cc
GROUP BY nome
GO
i´am explain :
i need to know for my customers the sum of all invoices that have expired in 30 days and over 30 days.
I hope someone could give me some help
thanks in advance
Luis santos
March 16, 2002 at 6:26 am
DATEDIFF ( datepart , startdate , enddate )
do
SUM(CASE WHEN DATEDIFF (d, datalc, getdate()) < 30 THEN deb ELSE 0 END) AS 30Days,
SUM (CASE WHEN DATEDIFF (d, datalc, getdate()) > 30 OR DATEDIFF (d, datalc, getdate()) < 60 THEN deb ELSE 0 END) AS 60Days
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
March 16, 2002 at 8:14 am
Many thanks for your help, i will try your sugestion
bye
Luis Santos
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply