NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Depends on your dialect (Score:2)
Date functions aren't really standard in SQL, so it's a question of what RDBMS you're using. For Sybase and SQL server, you could use
datediff(yy, @date1, @date2).Looks like you've got Oracle. In which case I think if you used months, you wouldn't have to worry about leap years:
But I haven't tested that.As usual, Ask Tom has a nice answer: an implementation of DateDiff in PL/SQL [oracle.com]. Looks nice and tidy too.
Reply to This
Re: (Score:1)
The trouble with months_between is that it doesn't return nice sharp integers, it returns floats. This always makes me wonder about things like whether 11.6 months round up to a year.
One more damned thing to go wrong, and all that.