Thursday, April 27, 2006

Min and Max functions

These 2 are missing in VBA, but I found them both useful:
Function Max(ByVal d1 As Date, ByVal d2 As Date) As Date
    Max = d1
    If d2 > d1 Then Max = d2
End Function

Function Min(ByVal d1 As Date, ByVal d2 As Date) As Date
    Min = d1
    If d2 < d1 Then Min = d2
End Function

2 comments:

  1. Thanks for comments! I never used this function in query, so good to know!

    ReplyDelete
  2. Hi,
    Agree, that makes sense, but in most cases i use subqueries for such long-sql queries

    ReplyDelete