Hi everyone. I am looking to compare dates in SQL - do a bit of arithmetic on them. What I have is:Two events - Buying a car, and Servicing the car. I am interested in the people who have had to take their car in for a service within one month of buying their car. So the code I have is:SELECT * FROM(SELECT DISTINCT Customer, Event_type, Event_dateFROM DatabaseWHERE EVENT_type = "Purchase") AINNER JOIN (SELECT DISTINCT Customer, Event_type, Event_dateFROM DatabaseWHERE EVENT_type = "Service") B-- bit of code I am struggling with belowWHERE B.Event_date - A.Event_date BETWEEN '1' AND '30'
So my logic is that if the service date - the purchase date is between 1 and 30, then they have taken their car in for a service within the first 30 days of having it.Any help with that last line of code?Thanks in advance!