“I need to create a field that will show the number of days between a date and the present.
TABLE: reg_add
+------------+---------+
| Name | Type |
+------------+---------+
| hm_date | date |
+------------+---------+
| total_days | date |
+------------+---------+
My client will type in the following date for example in “hm_date”: May 1, 2012.
I need “total_days” to show the total days between May 1, 2012 at the current date.
I want to achieve this on server-side, which is somewhat new to me.
I need to create a TRIGGER to always have “total_days” updated
I started with this and I’m having trouble making a trigger and getting it correct:
SELECT DATEDIFF(curdate(),hm_date) as total_days FROM reg_add
Any help would be appreciated.
Erik
Erik, I am using tsql, and not as familiar with mySQL, but in tsql the
DATEDIFFfunction requires 3 parameters. The sytax isI would try
DATEDIFF(d,GETDATE(),hm_date) AS total_days FROM reg_add