onedumbcoder Posted June 2, 2009 Share Posted June 2, 2009 I want to the query to return the minutes left for a user to delete an entery. for example lets say once a user enters a record he/she has 5mins to delete it before it can no longer be deleted. I want to know how I can do that. I have this DATEDIFF(DATE_ADD(date_stamp, INTERVAL 5 MINUTE), NOW()) but this does not work, is it possible to have something like this return to me the mins? Thanks in advanced for the help! Link to comment https://forums.phpfreaks.com/topic/160593-solved-mysql-return-the-difference-in-minutes/ Share on other sites More sharing options...
Ken2k7 Posted June 2, 2009 Share Posted June 2, 2009 Example (not tested) SELECT IF(TIMESTAMPDIFF(MINUTE, TIMESTAMP(date_stamp), NOW()) <= 5, 1, 0) AS deletable FROM tablename WHERE user_id = '1' LIMIT 1; If 1, the user can delete. If 0, the user can't delete. Link to comment https://forums.phpfreaks.com/topic/160593-solved-mysql-return-the-difference-in-minutes/#findComment-847533 Share on other sites More sharing options...
onedumbcoder Posted June 3, 2009 Author Share Posted June 3, 2009 thanks Ken but that function would not work for me, I am not sure why, maybe I am using an older version of mysql that does not support that? Anyhow I figured out a solution MINUTE(DATE_ADD(date_stamp, INTERVAL 6 MINUTE)) - MINUTE(NOW()) Link to comment https://forums.phpfreaks.com/topic/160593-solved-mysql-return-the-difference-in-minutes/#findComment-848326 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.