my $update="UPDATE `ml_message` SET `message_send`='N',`message_has_been_sent`='2010-12-06 10:59:20' WHERE `message_id`=3;"; $dbh->do($update) or die "problem while updating: $dbh->errstr \n"; #### -- -- Versione MySQL: 5.0.22 - SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `test` -- -- -------------------------------------------------------- -- -- Table schema `test_table` -- CREATE TABLE `test_table` ( `test_id` int(10) unsigned NOT NULL auto_increment, `test_cl_1` tinyint(1) NOT NULL, `test_cl_2` datetime default NULL, PRIMARY KEY (`test_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Data Dump for table `test_table` -- INSERT INTO `test_table` (`test_id`, `test_cl_1`, `test_cl_2`) VALUES (3, 1, '2010-12-07 14:01:28'), (4, 0, '2010-12-07 14:04:35'); #### use strict; use warnings; use DBI; use constant DB_HOST=>'localhost'; use constant DB_NAME=>'test'; use constant DB_USR=>'testUser'; use constant DB_PWD=>''; sub localDate { my $ora; unless (@_) { # se non ci sono parametri $ora=time; # ora e' il timestamp } else { $ora= shift @_; # altrimenti ora e' il primo parametro } my ($sec,$min,$hour,$mday,$mon,$year,$wday, $yday,$isdst)=localtime(time); sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec; } my $dbh = DBI->connect( 'DBI:mysql:'.DB_NAME.':'.DB_HOST,DB_USR,DB_PWD) or die "Connecting : $DBI::errstr\n "; my $ora=&localDate; print "\n\n"; print 'date: '.$ora; print "\n\n"; my $update="UPDATE `test_table` SET `test_cl_1`=1,`test_cl_2`='$ora' WHERE `test_id`=4;"; print "\n\n"; print $update; print "\n\n"; $dbh->do($update) or die "problem while updating: $dbh->errstr \n";