- Joined
- Jun 1, 2012
- Messages
- 33
- Reaction score
- 0
Hey all, I have a very tricky IIF statement Im using in Access 2010...
What I have - a PlaceKPI time [PlaceKPI12] and a Place Actual time [PlaceAct12] the KPI time is 23:00 hrs {11pm} and the place Actual time can be anywhere from 22:00 hrs {10pm} through to 03:00 hrs {3am}.
If the time is after 23:00, it should show a - result in Minutes (Display's correctly)
If the time is after midnight shows a negitive result (Display's correctly)
However if the time ACT place time is early, it shows a negitive result (Not right)
Below is the statement I'm useing, can anyone read this and see my mistake, I would really appreciate your help.
Cheers
Bar_NZ
=IIf([PlaceKPI12]>[PlaceACT12] And Abs(DateDiff("n",[PlaceKPI12],[PlaceACT12]))>120,DateDiff("n",DateAdd("n",1440,[PlaceACT12]),[PlaceKPI12]),IIf([PlaceKPI12]<[PlaceACT12] And Abs(DateDiff("n",[PlaceKPI12],[PlaceACT12]))>120,DateDiff("n",DateAdd("n",1440,[PlaceKPI12]),[PlaceACT12]),DateDiff("n",[PlaceKPI12],[PlaceACT12])))
What I have - a PlaceKPI time [PlaceKPI12] and a Place Actual time [PlaceAct12] the KPI time is 23:00 hrs {11pm} and the place Actual time can be anywhere from 22:00 hrs {10pm} through to 03:00 hrs {3am}.
If the time is after 23:00, it should show a - result in Minutes (Display's correctly)
If the time is after midnight shows a negitive result (Display's correctly)
However if the time ACT place time is early, it shows a negitive result (Not right)
Below is the statement I'm useing, can anyone read this and see my mistake, I would really appreciate your help.
Cheers
Bar_NZ
=IIf([PlaceKPI12]>[PlaceACT12] And Abs(DateDiff("n",[PlaceKPI12],[PlaceACT12]))>120,DateDiff("n",DateAdd("n",1440,[PlaceACT12]),[PlaceKPI12]),IIf([PlaceKPI12]<[PlaceACT12] And Abs(DateDiff("n",[PlaceKPI12],[PlaceACT12]))>120,DateDiff("n",DateAdd("n",1440,[PlaceKPI12]),[PlaceACT12]),DateDiff("n",[PlaceKPI12],[PlaceACT12])))