How about this (note that the inputs are dates entered as yyyymmdd - so October 1, 2006 would be 20061001):
Function GA(edc As String, dd As String, today As String) As String
'Gestational Age (GA)
If IsMissing(today) Then
today = Format(Now, "yyyymmdd")
End If
If IsMissing(edc) Then
GA = "n/a"
Else
Select Case DateSerial(Left(dd, 4), Mid(dd, 5, 2), Right(dd, 2))
Case Is = ""
GA_Days_Total = 280 + Int(DateSerial(Left(edc, 4), Mid(edc, 5, 2), Right(edc, 2)) _
- DateSerial(Left(today, 4), Mid(today, 5, 2), Right(today, 2)))
Case Else
GA_Days_Total = 280 + Int(DateSerial(Left(edc, 4), Mid(edc, 5, 2), Right(edc, 2)) _
- DateSerial(Left(dd, 4), Mid(dd, 5, 2), Right(dd, 2)))
End Select
End If
GA_Weeks = Fix(GA_Days_Total / 7)
GA_days = GA_Days_Total Mod 7
GA = Format(GA_Weeks, "0") & " " & Format(GA_days, "0") & "/7 weeks"
End Function
Does this help?
Bookmarks