I want to create a function to return the gestational age of babies on
their date of birth (DOB) with reference to the due date (the
estimated date of confinement or EDC).
The function I have at the moment is:
Function Gest(DOB As
Variant, EDC As Variant) As Single
'Returns the gestation in the form x.y where x is the number of
'and y is the additional days, which can range from 0 to 6.
'The calculation is based on the DOB and the EDC, and assumes a normal
'duration of 280 days, with the start being day 0 (not day 1).
Dim Gestation As Double
((280 - (EDC - DOB)) 7) + (0.1 * ((280 - (EDC - DOB))
Gest = Gestation
When I test this within the immediate window I get the
result I expect
However, when using the function in a worksheet with the same DOB and
EDC I see a value of 31.3999996185302 (when I use formula auditing).
I had wanted to compare my calculation to the value displayed in an
existing 'gestation' column.
1. What is causing this behaviour?
2. Can I return the function value (as displayed in the immediate
window) to the worksheet cell?