Group:  Microsoft Access ยป microsoft.public.access.tablesdbdesign
Thread: Add 7 days to last record date?

Add 7 days to last record date?
Zach 12/23/2008 5:25:00 PM
Hello,
I am still a novice at database design so maybe this will be easy. I
would like the default value for my date column to continually increase by
seven days. It is a schedule and the date value needs to be every Monday.
RE: Add 7 days to last record date?
Dale Fye 12/23/2008 7:56:35 PM
Which Monday. The most recent Monday, or the Next Monday?

Set the default value to something like:

=Dateadd("d", -1 * weekday(date(), vbMonday) + 1, date())

This will give you today (if today is a monday), or the most recent Monday
already completed.

You can either set this as the default value of the field (in the database
table), or in the control that is bound to that field on a form.

To get the upcoming Monday, use:

=Dateadd("d", 7- weekday(date(), vbMonday) + 1, date())

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"Zach" wrote:

[Quoted Text]
> Hello,
> I am still a novice at database design so maybe this will be easy. I
> would like the default value for my date column to continually increase by
> seven days. It is a schedule and the date value needs to be every Monday.
RE: Add 7 days to last record date?
Dale Fye 12/23/2008 8:34:06 PM
My previous reply does not seem to have posted properly.

To get the most recent Monday, try:
=Dateadd("d", - weekday(date(), vbTuesday), date())

To get the next Monday, try:
Dateadd("d", 7- weekday(date(), vbTuesday), date())

The Weekday( ) function returns the numeric value of the day of the week,
and accepts an optional second parameter which allows you to set the start
day of the week. In this case, we are using Monday as the start day of the
week.

So, Weekday(Date(), vbTuesday) will return 1 on 23 Dec, and subtracting 1
from 23 gives you 22.

If you are putting this in the default value of the field, in a table, you
will probably have to replace vbTuesday with the value 3
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"Zach" wrote:

[Quoted Text]
> Hello,
> I am still a novice at database design so maybe this will be easy. I
> would like the default value for my date column to continually increase by
> seven days. It is a schedule and the date value needs to be every Monday.
RE: Add 7 days to last record date?
Sam H 12/24/2008 1:27:01 AM
Hi Zach,
Try:

=Date()+7

Regards,
Sam
RE: Add 7 days to last record date?
Zach 12/25/2008 11:35:00 PM
I only make the schedule once every six weeks, so I need it to look at the
last record and add 7 days to it. It just gets tedious entering all those
dates.

"Dale Fye" wrote:

[Quoted Text]
> My previous reply does not seem to have posted properly.
>
> To get the most recent Monday, try:
> =Dateadd("d", - weekday(date(), vbTuesday), date())
>
> To get the next Monday, try:
> Dateadd("d", 7- weekday(date(), vbTuesday), date())
>
> The Weekday( ) function returns the numeric value of the day of the week,
> and accepts an optional second parameter which allows you to set the start
> day of the week. In this case, we are using Monday as the start day of the
> week.
>
> So, Weekday(Date(), vbTuesday) will return 1 on 23 Dec, and subtracting 1
> from 23 gives you 22.
>
> If you are putting this in the default value of the field, in a table, you
> will probably have to replace vbTuesday with the value 3
> --
> HTH
> Dale
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "Zach" wrote:
>
> > Hello,
> > I am still a novice at database design so maybe this will be easy. I
> > would like the default value for my date column to continually increase by
> > seven days. It is a schedule and the date value needs to be every Monday.

Home | Search | Terms | Imprint
Newsgroups Reader