Loosing the battle - Datediff working but I want to apply a condition -
i know i'm gonna 'kick myself' when see answer right can't see it.
select [faxdate] ,datediff(day, cast(substring(rpt.faxdate, 1, 4) + '-' + substring(rpt.faxdate, 5, 2) + '-' + substring(rpt.faxdate, 7, 2) date), getdate()) vdiff
faxdate vdiff
20130704 62
20130705 61
20130705 61
20130708 58
works great, want able test number of days eg. records on 60 days. when add :
where (datediff(day, cast(substring(rpt.faxdate, 1, 4) + '-' + substring(rpt.faxdate, 5, 2) + '-' + substring(rpt.faxdate, 7, 2) date), getdate()) >60)
i get: conversion failed when converting date and/or time character string.
i have tried sql derived table , tested vdiff ....i'm not doing right
any appreciated
ttfn
martyn
(cornwall england , it's not raining .. result !)
try
select [faxdate],day(datediff(cast(substring(rpt.faxdate, 1, 4) + '-' + substring(rpt.faxdate, 5, 2) + '-' + substring(rpt.faxdate, 7, 2) date), getdate())) vdiff
instead of using where, use having below
having vdiff > 60
Comments
Post a Comment