Hi,
I have a table named as appointment. In appointment there are two fields appointment_date and person_id. There can be multiple appointment for same person. What I want to achieve here is that the date difference of both appointments for the same person should be greater or equal to 90 days and I want to be sure that the time difference is taken from two different rows not 1 row.
Can anyone tell me that how can I achive this.
Thanks in advance.

If you do

SELECT COUNT(*)
  FROM appointments
 WHERE NAME = 'Jim'
   AND ABS(DATEDIFF(day,appt_date,GETDATE())) < 90

then you will get 0 if there are no appointments booked for Fred within 90 days of today. Just substitute the proposed appointment date for GETDATE().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.