[AccessD] First / last day of week

Robert L. Stewart rl_stewart at highstream.net
Mon Jan 15 13:27:50 CST 2007


John,

If this is for your monster SQL
database, you should be using a
date dimension table with the date
as the PK and all of the things like
day of week, day of year, day of month,
year, etc. as columns so there is no
date math to calculate anything like what
you are doing.

And, it works with Access databases also.

Robert

At 12:00 PM 1/15/2007, you wrote:
>Date: Mon, 15 Jan 2007 12:57:38 -0500
>From: "JWColby" <jwcolby at colbyconsulting.com>
>Subject: [AccessD] First / last day of week
>To: "'Access Developers discussion and problem solving'"
>         <accessd at databaseadvisors.com>
>Message-ID: <000a01c738ce$a60c4970$657aa8c0 at m6805>
>Content-Type: text/plain;       charset="us-ascii"
>
>Has anyone got more efficient code than the following?
>
>Function DteFirstDayOfWeek(dte As Date) As Date
>Dim intDOW As Integer
>     intDOW = Weekday(date, vbUseSystemDayOfWeek)
>     DteFirstDayOfWeek = date - (intDOW - 1)
>End Function
>
>Function DteLastDayOfWeek(dte As Date) As Date
>Dim intDOW As Integer
>     intDOW = Weekday(date, vbUseSystemDayOfWeek)
>     DteLastDayOfWeek = date + (7 - intDOW)
>End Function
>
>John W. Colby
>Colby Consulting
>www.ColbyConsulting.com
>





More information about the AccessD mailing list