简体   繁体   中英

Compare date in MySQL database from a Perl script

I've a Perl script with a MySQL query as below

my $date         = strftime "%Y-%m-%d", localtime;

my $db_passwdcol = "password";
my $db_table     = "users";
my $db_usercol   = "username";
my $db_cond      = "expire_date";

my $sql_query    = "SELECT $db_passwdcol FROM $db_table WHERE $db_usercol = ?" . ($db_cond gt $date ? ");

What I want to do is compare current with the expired date ones using an SQL query. I've tried many variations but hopeless.

Thanks in advance,

To change sql query string as below that worked for me;

 $sql_query = "SELECT $db_passwdcol FROM $db_table WHERE $db_usercol = ? AND $db_cond > NOW()";

Best,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM