I am attempting to write a query that will take a date value and return a numerical value. What I plan to use this for is to track the days until an inspection is due. For example I will input the inspection expiration date into the database, then I want the query to return the value of days remaining until the inspection is due.
Thanks for the help. I am not that good with SQL. I know how to write basic queries but anything past that I really don't know what to do.
You can use timestampdiff()
function to get the remaining days.
Lets say the expire date is 2014-10-31
and comparing with now you can get the days as
mysql> select timestampdiff(day,now(),'2014-10-31') as days ;
+------+
| days |
+------+
| 11 |
+------+
1 row in set (0.00 sec)