Calculating calendar year for a student based on DOB
I think this is equivalent to your function.

year1 &lt;- function(dob) as.numeric(format(dob, "%Y")) + 6 +
    (as.Date("1997-07-01") &lt;= dob &amp; 7 &lt;= as.numeric(format(dob, "%m")))


You would run it like this.

&gt; test &lt;- c(as.Date("1985-09-15"),as.Date("1999-02-15"),as.Date("2004-08-15"))
&gt; year1(test)