Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate the days elapsed since last visit 1

Status
Not open for further replies.

BxWill

MIS
Mar 30, 2009
367
US
In the sql server script within sql server 2005, I have the following lines;

CustomerName
,CustomerID
,convert(varchar,CustomerDateOfBirth,101)CustBirthDt
,convert(varchar,CustomerVisitDate,101)CustVisitDt
,datediff(dd,cust_birth_dt,getdate())/365.0 as CustAge
,datediff(dd,cust_birth_dt,visit_date)/365.0 as AgeAtVisit

Is it possible to modify the sql script to display the days elapsed since the last visit for each customer?

I would think that the data need to be ordered by CustomerName (ascending order) and then by CustomerVisitDate (ascending order).


 
Code:
....
,datediff(dd,visit_date, GETDATE()) as DaysAfterLastVisit
...

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top