Number of days

(I’m trying to calculate the number of days from start to finish of the project)

I have 3 fields

ProjectStartDate (Value @Today)

ProjectCompletionDate (Valuel @Today)

NbrConstructionDays ( defined as Number field)

I have the following code on my QuerySave event

Dim NbrConstructionDaysHold As Variant

NbrConstructionDaysHold = (ProjectCompletionDate - ProjectStartDate )

doc.NbrConstructionDays = NbrConstructionDaysHold

The field value of NbrConstructionDays always caluclates the number 0

WHAT AM I DOING WRONG? THANKS SO MUCH FOR YOUR HELP.

Subject: Perhaps this?

Dim NbrConstructionDaysHold As VariantNbrConstructionDaysHold = (doc.ProjectCompletionDate(0) - doc.ProjectStartDate(0)) ’ value is in seconds

doc.NbrConstructionDays = NbrConstructionDaysHold / 60 / 60 / 24 ’ now value is in days

Subject: RE: Perhaps this?

Thanks for your help. It was the doc. and (0) that fixed it.

Thanks again.

Subject: Number of days

Hmmm. I’m a bit confused. Are the fields on the form computed when composed? At first glance, it would look like you’re doing:@Today - @Today and a number minus itself is always going to be zero.

One of the things you might want to do first is to set “Option Explicit”. That forces you to define and declare variables.

Again, it’s hard to see what you’re doing, but shouldn’t your code be something like this (given your form):

NbrConstructionDaysHold = (doc.ProjectCompletionDate(0) - doc.ProjectStartDate(0))

?

Just wondering.

I think for this you might want to look at the reference for the NotesDateTime class and particularly the method “TimeDifference”

Good luck