09-08-2014 02:56 PM
I'm trying to write a query based upon two dates (Date1 and Date2) to determine if Date 2 is within 30 days of Date1 in Query Builder.
What is the best what to write this query?
09-08-2014 03:07 PM
If the variables are actually SAS date values, which is a good idea with any date value, then the condition can be expressed as: abs(date1-date2) le 30 (if exactly 30 days is acceptable, otherwise < 30)
09-08-2014 03:23 PM
input date1 date2;
format date1 mmddyy10. date2 mmddyy10.;
informat date1 mmddyy10. date2 mmddyy10.;
length flag $60.;
if date2-date1 le 30 then flag='date 2 is with in 30 days of date 1';
else flag='date 2 is with NOT in 30 days of date 1';
09-08-2014 04:09 PM
I tried the following:
1. Using the INTCK Function I chose the two dates to calculate the amount of days between 9See below).
2. Ran the query and got the following results:
EffCess AccDate EffCessAccDateDays
04/05/2013 06/11/13 67
3. Ran a query (see below).
t1.EffCessAccDate_Days = 30
This query will display all records with t1.EffCessAccDate_Days = 30
Is this another good solution?
Am I missing something?