Slash Boxes
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

use Perl Log In

Log In

[ Create a new account ]

miyagawa (1653)

  (email not shown publicly)
AOL IM: bulknews (Add Buddy, Send Message)

Journal of miyagawa (1653)

Wednesday October 25, 2006
12:15 PM

DateTime::Span::Birthdate is on CPAN

[ #31419 ]

(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:

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.