[AccessD] Getting the start and end dates of the current week

Jürgen Welz jwelz at hotmail.com
Fri Feb 27 19:01:50 CST 2004


I wrote a few standard functions that give me fiscal year (Oct 31 year end, 
good old two digit format) and start and end dates of the current/next week 
that could serve as a starting point.  These should be regionalized for 
different weekday start of week dates but works for Canada/US.

Function fnFiscalYr()
    If DatePart("m", Date) > 10 Then
        fnFiscalYr = Format$(Format$(Date, "yy") + 1, "00")
    Else
        fnFiscalYr = Right$(Format$(Date, "yy"), 2)
    End If
End Function

Function fnLastOfThisWeek() As Date
    fnLastOfThisWeek = DateSerial(Year(Date), Month(Date), Day(Date) + 7 - 
WeekDay(Date))
End Function

Function fnLastOfNextWeek() As Date 'change to + 7 for current week
    fnLastOfNextWeek = DateSerial(Year(Date), Month(Date), Day(Date) + 14 - 
WeekDay(Date))
End Function

Function fnFirstOfNextWeek() As Date
    fnFirstOfNextWeek = DateSerial(Year(Date), Month(Date), Day(Date) + 8 - 
WeekDay(Date))
End Function

Function fnLastOfMonth() As Date
    fnLastOfMonth = CDate(Format$(DateAdd("m", 1, Date), "m/1/yy")) - 1
End Function


Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com





>From: "Christopher Hawkins" <clh at christopherhawkins.com>
>
>I need a function that will determine the start and end dates of the
>current week.  I'm hacking around with some code, but I'm not
>producing enything useful.  Surely I'm not the first to have this
>problem?
>
>-Christopher-

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*  
http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca




More information about the AccessD mailing list