FredixBlog


Just my log about anything I could find enjoyable.



WeekNumber(Date)

author Posted by: fredometro on date Jan 1st, 2004 | filed Filed under: MS-Access

Gives the week number of any date. The second week starts the first monday in the year.


Public Function WeekNumber(ByVal TheDate As Date)
Dim ToDay, WeekTwoMonday As Date

WeekNumber = Val(Format(TheDate, "ww"))
If WeekDay(DateSerial(Year(TheDate), 1, 1), vbMonday) > 4 Then
      WeekNumber = WeekNumber - 1
      If WeekNumber = 0 Then
            WeekNumber = WeekNumber(DateSerial(Year(TheDate) - 1, 12, 31))
      End If
End If

If WeekNumber >= 52 Then
      If WeekDay(DateSerial(Year(TheDate) + 1, 1, 1), vbMonday)&lt;= 4 And DateDiff("d", TheDate, DateSerial(Year(TheDate) + 1, 1, 1)) < 7 Then
            WeekNumber = 1
      End If
End If
End Function

No related posts.

     Add A Comment

You must be logged in to post a comment.


Warning: include(/home/www/web421/html/phpTraffic/write_logs.php) [function.include]: failed to open stream: No such file or directory in /home/websitef/public_html/fredometro.com/wp-content/themes/blueshadow/footer.php on line 15

Warning: include() [function.include]: Failed opening '/home/www/web421/html/phpTraffic/write_logs.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/websitef/public_html/fredometro.com/wp-content/themes/blueshadow/footer.php on line 15