Solved

# Access 2000 - Custom week calculation

Posted on 2011-05-12
228 Views
Dear Experts,

I need to calculate weeks in Access from date following such logic

- if the date is smaller than today --> week0
- if the date is this week --> week0
- if the date is next week --> week1
- if the date is after next week --> week2

Basically the actual week is from monday to sunday, so as today is 2011-05-13 that is 6 by this formula - TodayWeekday: Weekday(Date()). This can have importance that the next week always starts at Monday so when the TodayWeekday is 2.

thanks,
0
Question by:csehz

LVL 92

Accepted Solution

If you would want the week number to keep increasing as you extend out into the future:

``````SELECT Date() AS Today, SomeDate,
"week" & DateDiff("ww", Date(), IIf(SomeDate < Date(), Date(), SomeDate), 2) AS WeekNum
FROM SomeTable
``````
0

LVL 1

Author Closing Comment

This is perfect to me, thanks very much
0

## Featured Post

This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …