need a slicker way

Discussion in 'Microsoft Access Getting Started' started by mcnews, Feb 9, 2012.

1. mcnewsGuest

to do this:

....
ElseIf (Day(Date) > 12 And Month(Date) = 12 And Day(Date) < 18 And Month(Date) = 12) Then
Week = "49"
ElseIf (Day(Date) > 19 And Month(Date) = 12 And Day(Date) < 25 And Month(Date) = 12) Then
Week = "50"
ElseIf (Day(Date) > 26 And Month(Date) = 12 Or Day(Date) < 1 And Month(Date) = 1) Then
Week = "51"
ElseIf (Day(Date) > 2 And Month(Date) = 1 And Day(Date) < 8 And Month(Date) = 1) Then
Week = "52"
ElseIf (Day(Date) > 9 And Month(Date) = 1 And Day(Date) < 16 And Month(Date) = 1) Then
Week = "1"
ElseIf (Day(Date) > 16 And Month(Date) = 1 And Day(Date) < 23 And Month(Date) = 1) Then
Week = "2"
ElseIf (Day(Date) > 23 And Month(Date) = 1 Or Day(Date) < 30 And Month(Date) = 1) Then
Week = "3"
....

mcnews, Feb 9, 2012

2. mcnewsGuest

Public Function FluWeek(ByVal sDate As Date) As String
Dim x As Integer
x = Int((CDate(sDate) - CDate("10/23/2011")) / 7) + 42
If x > 52 Then
x = x - 52
End If
FluWeek = Trim(Str(x))
End Function

mcnews, Feb 9, 2012