$month=`date --date='1 month ago' +%B`;
my $sth = $dbh->prepare("SELECT * from $table where monthname(Date)='$month'" );
####
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\alex>date --date='1 month ago' +%B
The system cannot accept the date entered.
Enter the new date: (dd-mm-yy)
####
my $month=(localtime())[4]+1;
...
my $sth=$dbh->prepare("SELECT * from $table where month(Date)=?");
$sth->execute($month);
...
####
my $month=(localtime())[4]+1;
# last month:
$month--;
$month||=12;
...
my $sth=$dbh->prepare("SELECT * from $table where month(Date)=?");
$sth->execute($month);
...
####
my $lastmonth=(localtime())[4]||12;
...
my $sth=$dbh->prepare("SELECT * from $table where month(Date)=?");
$sth->execute($lastmonth);
...
####
...
my $sth=$dbh->prepare('SELECT * from '.$dbh->quote_identifier($table).' where month(Date)=?');
...