Example of dateDiff
– requirement: get agreementVersionID where the transactiondate is within 30 days from the billingcoveragestartdate
– transactiondate = 30-06-2007 between 28-09-2007
select top 100 agreementversionid, billingcoveragestartdate, transactiondate from pansales..licensetransactionitem
where billingcoveragestartdate is not null
and transactiondate between ‘06-30-2007′ and ‘09-28-2007′
and datediff (d,transactiondate,billingcoveragestartdate)