Link to home
Start Free TrialLog in
Avatar of willsherwood
willsherwood

asked on

MYSQL: date_time subtraction

I have two fields of type date-time:   LastTransaction and LastNotified
I have a ReminderThreshold field (integer) representing **hours**.

How can i get a WHERE selector boolean to represent the following equation (expressed in meta-English)

SELECT ...   WHERE    
  ((NOW() - LastTransaction) > (ReminderThreshold * conversionfactor))
  AND
  ((NOW() - LastNotification) > (ReminderThreshold * conversionfactor))

and converstionfactor converts the hours field into whatever the  internal MYSQL units are ??

Thus i want the row to be selected:
 IF the LastTransaction was more than X hours ago
AND
IF the LastNotification was not less than  X hours ago

I hope i'm not confusing the issue by giving the context... the crux of what i need to know is the conversionfactor  (and any strategy advice)
(and i'm not concerned about    > vs. >=   )

thanks

ASKER CERTIFIED SOLUTION
Avatar of miqrogroove
miqrogroove
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
also x DAY can be x HOUR, x MINUTE, x SECOND
Avatar of willsherwood
willsherwood

ASKER

thanks to all!   excellent