Dear friends,
hello to everyone!
I have a from and a report, which calculates the difference between 2 dates.
The fields called [Accidentdate] (the day accident happened) and [Employ Date] (the employment date).
On the same form/report, after i enter the accident date, then 3 different fields are auto calculated according to those 2 dates.
Desription below shows the calculation on each field.
My problem is that i have wrong results.
If accident date is 06/07/2016 and employ date is 01/07/2016, instead of getting
0 years
0 months
5 days
i get
0 years
1 month
25 days
Years field: =Abs(Int(DateDiff("m";[AccidentDate];[Employ Date])/12))
Months field : =Abs(IIf([DaysDiff]>=0;DateDiff("m";[AccidentDate];[Employ Date])-(Int(DateDiff("m";[AccidentDate];[Employ Date])/12)*12);DateDiff("m";[AccidentDate];[Employ Date])-(Int(DateDiff("m";[AccidentDate];[Employ Date])/12)*12)-1))
Days field: =Abs(IIf([daysdiff]>=0;DateDiff("d";DateAdd("m";DateDiff("m";[AccidentDate];[Employ Date]);[AccidentDate]);[Employ Date]);DateDiff("d";DateAdd("m";DateDiff("m";[AccidentDate];[Employ Date])-1;[AccidentDate]);[Employ Date])))
Any suggestions please? :banghead:
hello to everyone!
I have a from and a report, which calculates the difference between 2 dates.
The fields called [Accidentdate] (the day accident happened) and [Employ Date] (the employment date).
On the same form/report, after i enter the accident date, then 3 different fields are auto calculated according to those 2 dates.
Desription below shows the calculation on each field.
My problem is that i have wrong results.
If accident date is 06/07/2016 and employ date is 01/07/2016, instead of getting
0 years
0 months
5 days
i get
0 years
1 month
25 days
Years field: =Abs(Int(DateDiff("m";[AccidentDate];[Employ Date])/12))
Months field : =Abs(IIf([DaysDiff]>=0;DateDiff("m";[AccidentDate];[Employ Date])-(Int(DateDiff("m";[AccidentDate];[Employ Date])/12)*12);DateDiff("m";[AccidentDate];[Employ Date])-(Int(DateDiff("m";[AccidentDate];[Employ Date])/12)*12)-1))
Days field: =Abs(IIf([daysdiff]>=0;DateDiff("d";DateAdd("m";DateDiff("m";[AccidentDate];[Employ Date]);[AccidentDate]);[Employ Date]);DateDiff("d";DateAdd("m";DateDiff("m";[AccidentDate];[Employ Date])-1;[AccidentDate]);[Employ Date])))
Any suggestions please? :banghead: