Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select month from MYSQL query 1

Status
Not open for further replies.

skosterow

Technical User
Feb 23, 2002
135
US
Heya Gang -

I need to select ONLY the Month from a Query in mysql. Assuming that date is a date stamp, in a DB called open. and i want to return all months that are Jan (or 01). Im lost please help. Here's my code:

my $dsn = "DBI:mysqlPP:TTCOpen:$DB::SERVER";
my $dbh = DBI->connect($dsn, $DB::USER, $DB::pASS);
my $sth = $dbh->prepare(qq{ SELECT date FROM open WHERE callinby = '01'});
$sth->execute();
while (($TT::NUMBER) = $sth->fetchrow_array())
{ $STAFF::OPEN = $STAFF::OPEN + 1; $TOTAL::OPEN = $TOTAL::OPEN + 1; }
$sth->finish();
$dbh->disconnect();
 
Code:
SELECT date FROM open WHERE callinby = '01'
and extract(month from date) = 1
 
Thanks alot!

I assume that i could extact the year as: and extract(year from date) = 2003
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top