-1

here's my SQL data .. How to add 1 Hour on the last activity. That after updating it will be 2015-05-01 20:24:42 ? Thank you

 lastActivity   
 2015-05-01 19:24:42
Jay Viluan
  • 1,571
  • 3
  • 12
  • 16
  • Have you tried anything? Here's a [SO](http://stackoverflow.com/questions/589652/add-2-hours-to-current-time-in-mysql) article showing how it's done... assuming that is an actual date time data type – xQbert May 01 '15 at 16:31

1 Answers1

0

U can use the SQL function DATEADD

DATEADD(hh, 1, last_activity)

Example query:

SELECT user_id, DATEADD(hh, 1,last_activity) AS new_activity_date FROM users
Dees Oomens
  • 4,554
  • 3
  • 29
  • 61
  • can i ask question if how to query lastActivity that exactly 1hr from now.. for example i have in my database 2015-05-01 19:46:59 and 2015-05-01 21:42:21 so the output must be 1 only, which is 2015-05-01 19:46:59 because its in the range if you add 1 hour from now.. – Jay Viluan May 01 '15 at 16:52
  • I'm not sure if i get you question right but if i do the answer is: DATEADD(hh, 1, now()) AS new_activity_date. This will add 1 hour to the current time. – Dees Oomens May 01 '15 at 17:02
  • yes I already add 1 hr from lastActivty.. So my question now if u know how to query users that active 1hour exact from the current time.. for my example.. i have two users which is 2015-05-01 19:46:59 and 2015-05-01 21:42:21 the difference is 2hrs so i how can i query user for example the time is 2015-05-01 19:47:59 so 1hr from the 2015-05-01 21:42:21 is not in the range so it will not be query.. only the 2015-05-01 19:46:59 – Jay Viluan May 01 '15 at 17:08