I know I'm gonna 'kick myself' when I see the answer but right now I can't see it.
SELECT [faxdate]
,DATEDIFF(day,
CAST(SUBSTRING(RPT.FaxDate, 1, 4) + '-' + SUBSTRING(RPT.FaxDate, 5, 2) + '-' + SUBSTRING(RPT.FaxDate, 7, 2) AS DATE), getdate()) AS vDiff
faxdate vDiff
20130704 62
20130705 61
20130705 61
20130708 58
Works great, but I want to be able to test the number of days Eg. records over 60 days. When I add this :
WHERE (DATEDIFF(day,
CAST(SUBSTRING(RPT.FaxDate, 1, 4) + '-' + SUBSTRING(RPT.FaxDate, 5, 2) + '-' + SUBSTRING(RPT.FaxDate, 7, 2) AS DATE), getdate()) >60)
I get: Conversion failed when converting date and/or time from character string.
I have also tried this sql as a derived table and then tested vDiff ....i'm obviously not doing it right
any help would be appreciated
ttfn
Martyn
(Cornwall England and it's not raining .. result !)