Re: Allocating Dates
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Thu, 14 Feb 2008 11:48:04 +0900
Mark, you may be able to do this without a table, just using:
DatePart("ww", [SomeDate])
to get the week number from the date, or using:
DateAdd("ww", HowManyWeeks, FirstDateOfYear)
to get the starting date for a week from a week number.
DatePart() has soptional arguments to handle what you consider to be the first day of the week, and which is the first week of the year.
If you want to use a lookup table of dates (e.g. where the periods cannot be calculated), you are best to store only the first date in the period, and then use this kind of logic to figure out the ending date and consequently the period that any particular date belongs to:
Lookup in a range of values in a query
at:
http://allenbrowne.com/ser-58.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Mark A. Sam" <MarkASam@xxxxxxxxxxx> wrote in message
news:uCCJkTpbIHA.5984@xxxxxxxxxxxxxxxxxxxxxxx
Hello,
I need a procedure to allocated dates withing a date range into weeks with a starting and ending date for each week within the range. For example, if the selected date range is 2/1/08 to 2/21/08 the beggining and ending dates would be allocated like this:
Week Date1 Date1
1 2/1 2/2
2 2/3 2/9
3 2/10 2/16
4 2/17 2/21
I would need to create 4 records with those dates inserted into the date fields.
In my mind it would be taking the remaning days from starting date to the end of the first week, then allocating the dates for the remaining weeks based on the number of days remaining. I can't work out an efficient method.
If anyone can guide me somehow or if there is an example worked out, I'd appreciate any help.
Thanks and God Bless,
Mark A. Sam
.
- Follow-Ups:
- Re: Allocating Dates
- From: Mark A. Sam
- Re: Allocating Dates
- References:
- Allocating Dates
- From: Mark A. Sam
- Allocating Dates
- Prev by Date: Re: printing labels from a from
- Next by Date: Re: How load images that are in a folder onto a form
- Previous by thread: Allocating Dates
- Next by thread: Re: Allocating Dates
- Index(es):
Relevant Pages
|