Let's say we have a MYSQL database, 'employees.'
The database contains a column, "EXP," which contains a String signifying the persons START DATE... example: "2015-01-11" (formatted: yyyy-mm-dd)
I would like for database queries to return a variable "experience" which is calculated by comparing the current date to the date contained in the EXP column.
I have tried what seems to be a million different methods... via google, php docs, etc etc etc... but nothing seems to be working.
This is the most recent attempt... what I'm trying:
SELECT phone, name, (DATEDIFF('CURDATE()','EXP') AS experience, bio, photo, FROM squad
(DATEDIFF('CURDATE()','EXP') AS experience
you have extra brackets AND 'EXP' will use the string literal not the db field
SELECT phone, name, DATEDIFF(now(), exp) AS experience, bio, photo FROM squad
working demo: http://sqlfiddle.com/#!9/79e87/2