Date calcutation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good afternoon, i need some help with the following:
I have a maintenace DB, i have the following fields MachineHours (long int),
MaintenaceHours (long int), MaintenaceDate (date) and WeeklyHourWork (long
int). I have a text box NextMaintenace (date) where i calcute the date of the
next maintenace based on the date of the maintenace (MaintenaceDate)
difference between MachineHours, MaintenaceHours and WeeklyHourWork.
example:
if MachineHours=4000, MaintenaceHours=7000, MaintenaceDate=26-10-2007,
WeeklyHourWork=40
then
NextMaintenace=15-03-2009
This works fine but I need to put a limit to this MaintenaceDate so it can´t
be bigger than 1 year (365 days).
I've tried using IF-THEN-ELSE conditions but it didn't work very well.
Can somebody give me a clue how to do this?

Thanks in advance
 
You can find the difference between two dates with the datediff function.

If DateDiff("d", <START_DATE> ,END_DATE>) > 365 then
<Whatever happens when it's greater>
else
<Normal processing>
end if
 
Thanks Lancem,
Where do I put this code? Before Update or After Update?
i am making the calculation
(=[Maintenacedate]+((([MaintenaceHour]-[MachineHour])/[WeeklyHourWork])*7))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top