Hi,
I have table [Leave] and [LeaveDetail]. In table [Leave], i have field StaffNo and TotDays. In table [LeaveDetail], i have field StaffNo, StartDate and EndDate. Both table is linked by StaffNo. I want to update TotDays (equal to EndDate-StartDate+1).
This is what i've done,
This is the sample of data,
StartDate EndDate
02/01/2004 08/01/2004
so..the TotDays should be 8.
my problem is, it displays as 1.
it means, it doesn't calculate the total days..
any idea? thanx..
I have table [Leave] and [LeaveDetail]. In table [Leave], i have field StaffNo and TotDays. In table [LeaveDetail], i have field StaffNo, StartDate and EndDate. Both table is linked by StaffNo. I want to update TotDays (equal to EndDate-StartDate+1).
This is what i've done,
Code:
UPDATE [Leave] INNER JOIN [LeaveDetail] ON [Leave].[StaffNo]=[LeaveDetail].[StaffNo] SET [Leave].[TotDays] = ([LeaveDetail].[EndDate]-[LeaveDetail].[StartDate]+1)
WHERE ((([Leave].[StaffNo])=[LeaveDetail].[StaffNo]));
This is the sample of data,
StartDate EndDate
02/01/2004 08/01/2004
so..the TotDays should be 8.
my problem is, it displays as 1.
it means, it doesn't calculate the total days..
any idea? thanx..