I am stuck in getting the remaining days, hours and minutes between two dates in mySql.
I have an expiry date and I want to compare it with current DateTime and want to get days, hours and minutes.
This stackoverflow link may help you. There is many way to calculate difference between two dates and your are not oblige to do this in full SQL.
[EDIT]
I ve found a solution in SQL...
SELECT TIMESTAMPDIFF(DAY,NOW(),'2012-01-01') AS DAY,
TIMESTAMPDIFF(HOUR,NOW(),'2012-01-01')-TIMESTAMPDIFF(DAY,NOW(),'2012-01-01')*24 AS HOUR,
TIMESTAMPDIFF(MINUTE,NOW(),'2012-01-01')-TIMESTAMPDIFF(HOUR,NOW(),'2012-01-01')*60 AS MINUTE;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With