Senin, 06 Agustus 2012

[MS_AccessPros] Re: Week ending on Monday

 

Troy

I found another one in my library. This one, authored by A.D., is specifically for Monday's date and might be less cumbersome than the generalized one I posted earlier.

Function GetMondayDateForWeek(WkNum As Variant, YrNum As Variant) As Variant
'Purpose : Gets date on monday falling in the given week for given year.
' (Based upon Sunday as first day of the week)
'Note: If the week's Monday is a date belonging to prev year, it is OK.
'DateTime : 5/1/2007 13:58
'Author : A.D. Tejpal
Dim DtYrStart As Date
Dim WkDay As Long
Dim DtFirstMonday As Date

If IsNull(WkNum) Or IsNull(YrNum) Then Exit Function

DtYrStart = DateSerial(YrNum, 1, 1)
WkDay = Weekday(DtYrStart)
DtFirstMonday = DtYrStart + (2 - WkDay)

GetMondayDateForWeek = _
DateAdd("ww", (WkNum - 1), DtFirstMonday)

End Function

Bill

--- In MS_Access_Professionals@yahoogroups.com, "Troy Sherven" <tsherven@...> wrote:
>
> I'm writing an Access report showing data grouped by week, with the week
> ending on Monday. I was able to successfully accomplish the grouping
> I'm looking for using week number. Now my challenge is figuring out how
> to label the group footers. I want to add a label that say's something
> like "Week ending 8/6/2012" instead of "Week ending 32". My question
> is, how can I convert a week number into an actual date?
>
>
>
> Thanks,
>
>
>
> Troy Sherven
>
> MCD, Inc.
>
>
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar