DateTime::Span::Birthdate is on CPAN

miyagawa on 2006-10-25T17:15:30

(from datetime list)

DateTime::Span::Birthdate 0.01 is now going to CPAN.

This module is a port of Date::Range::Birth, which allows you to build a range of dates for birthdays of people with particular age. This makes it easy for you to build an SQL query for example, to select teenager users from your database which has 'birth' column as datetime.

 # build a datetime span for teenagers
 use DateTime::Span::Birthdate;
 my $span = DateTime::Span::Birthdate->new(from => 13, to => 19);

# build an SQL query in a raw way my $sql = "SELECT * FROM user WHERE birthday >= ? AND birthdy <= ?"

my $sth = $dbh->prepare($sql); $sth->execute($span->start->ymd, $span->end->ymd);


The code is also available in my subversion repository: http://svn.bulknews.net/repos/public/DateTime-Span-Birthdate/trunk