views:

158

answers:

1

I'm trying to do something like this:

SELECT MAX(
  ADDDATE(expirationdate, INTERVAL 1 YEAR),
  ADDDATE(now(), INTERVAL 1 YEAR)
)

That is, get "a year from now", or "a year from the expiration date stored in the table", whichever is greater (i'm renewing people's subscriptions).

This obviously doesn't work, since MAX() is for aggregation between rows, not for comparing 2 values. Is there a function that'll do this in MySQL? (i'd like to avoid doing an IF)

+5  A: 

greatest()

longneck
Thank you! I did try "largest", and "maximum" and they didn't work. Thanks!
Daniel Magliola