If there's a harder way to do something, I usually search tirelessly until I find it.
I have a people dbs with a form that includes ‘date of birth’ and ‘age’ calculated by a function. Additionally, I wanted to add the person’s astrological sign, looked up from source table, 'stbl_Sign':

So far the only way I have been able to successfully look up the ‘Sign’ is by converting ‘date of birth’ and the 'Signs' various ‘from’ and ‘to’ dates to integers based on their day of the year:
Day of the year is computed by this function:
Can anyone suggest a more elegant solution?
I have a people dbs with a form that includes ‘date of birth’ and ‘age’ calculated by a function. Additionally, I wanted to add the person’s astrological sign, looked up from source table, 'stbl_Sign':
So far the only way I have been able to successfully look up the ‘Sign’ is by converting ‘date of birth’ and the 'Signs' various ‘from’ and ‘to’ dates to integers based on their day of the year:
Code:
Public Function fn_Sign(dteDOB As Date) As String On Error Resume Next Dim strSign As String Dim intDOB As Integer Dim strmsg As String intDOB = fn_Yearday(dteDOB) If intDOB >= 357 Or intDOB < 19 Then fn_Sign = "Capricorn" Exit Function End If strSign = DLookup("Sign", "stbl_Sign", "[doyFrom]<=" & intDOB & " AND [doyTo]>=" & intDOB) fn_Sign = strSign End Function
Code:
Public Function fn_Yearday(dat As Date) As Integer 'Purpose: does the same as day for month 'Use to access an array where the index corresponds to days 'starts with 1 for the january first '?Yearday(#1/12/2004#) '>> 12 fn_Yearday = DateDiff("d", CDate("1/1/" & Year(dat)), dat) + 1 End Function
Comment