select
case
when Estimated_Start_Date >= Revised_Start_Date and Estimated_Start_Date >= Estimated_Comp_Date then Estimated_Start_Date
when Revised_Start_Date >= Estimated_Start_Date and Revised_Start_Date >= Estimated_Comp_Date then Revised_Start_Date
else Estimated_Comp_Date
end as START,
Estimated_Start_Date,
Revised_Start_Date,
Estimated_Comp_Date
from DATES
Option Compare Database
Public Function LargestOf3Dates(Optional dat1 As Date, Optional dat2 As Date, Optional dat3 As Date) As Date
Dim datMaxDate As Date
If IsDate(dat1) Then
datMaxDate = dat1
End If
If IsDate(dat2) Then
If IsNull(datMaxDate) Then
datMaxDate = dat2
Else
If dat2 > datMaxDate Then
datMaxDate = dat2
End If
End If
End If
If IsDate(dat3) Then
If IsNull(datMaxDate) Then
datMaxDate = dat3
Else
If dat3 > datMaxDate Then
datMaxDate = dat3
End If
End If
End If
If IsNull(datMaxDate) Then
'All three dates were null
'Determine what you want to return
Else
LargestOf3Dates = datMaxDate
End If
End Function
select
case
when Estimated_Start_Date >= Revised_Start_Date and Estimated_Start_Date >= Estimated_Comp_Date then Estimated_Start_Date
when Revised_Start_Date >= Estimated_Start_Date and Revised_Start_Date >= Estimated_Comp_Date then Revised_Start_Date
else Estimated_Comp_Date
end as START,
Estimated_Start_Date,
Revised_Start_Date,
Estimated_Comp_Date
from DATES -- Change to your table name
Steve