0

Is there any more elegant way how to write such a condition?

WHERE date<'".($date+1)."-07-01'

Something similar to

WHERE date<'{($date+1)}-07-01' 
user965748
  • 2,227
  • 4
  • 22
  • 30
  • 1
    [Parameterise prepared statements](http://stackoverflow.com/a/60496) and this "problem" goes away! – eggyal Jan 21 '13 at 00:32
  • Are you looking for the [`DATE_ADD()`](http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add) function? – inhan Jan 21 '13 at 00:40
  • SQL also had a `CONCAT()` function, or `ADDDATE()` – mario Jan 21 '13 at 00:40

1 Answers1

1
$date = 2013;
$truedate = ($date + 1) . "-07-01";

$preparedDb = new DB;
$preparedDb->prepare("SELECT * FROM T1 WHERE date < ?")
   ->execute(array($truedate));
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405