Why not just keep using epoch seconds (which is what I assume you mean when you say time() format)?. You can convert back and forth between between the epoch secs and Year/Month/Day/Time with localtime and Time::Local. MySQL will treat them as integers. Else you need to convert them to dates and use the MySQL date type and MySQL will do the comparisons as date.