2
    mysql_query("UPDATE tablename SET date = DATE_ADD(DATE(NOW() + INTERVAL 1 WEEK), INTERVAL 17 HOUR), INTERVAL 30 MINUTE)
        WHERE idevent = '2'")
or die(mysql_error());

I want to add 7 days to the date, but have the time aspect of datetime manually set. I have the code above, which works for the hour, but as soon as I add minutes it errors saying SQL syntax error.

Any ideas?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dee1983
  • 93
  • 2
  • 8

3 Answers3

4

You need another DATE_ADD() at the front of that expression, since you're doing two additions.

mysql_query("UPDATE tablename SET date = DATE_ADD(DATE_ADD(DATE(NOW() + INTERVAL 1 WEEK), INTERVAL 17 HOUR), INTERVAL 30 MINUTE) WHERE idevent = '2'");
//-------------------------------------^^^^^^^^^^^^^^^^^^^^
Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
0

What keeps you from adding 17*60+30 Minutes and keeping the code readable?

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
-1

4 open '(' and 5 closing ')'. Disbalans.

Odobenus Rosmarus
  • 5,870
  • 2
  • 18
  • 21