Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weekday Function

Status
Not open for further replies.

Cillies

Technical User
Feb 7, 2003
112
GB
Hi,

I have created a simple update query, that updates the date everyday.
i.e. any date before today's date will be updated to todays date. I have it running on an autoexec. macro

But what I really want to be able to do is update the DB everyday, but update the date for seven days time. but at the same time take into consideration the weekends. I just want to use the 5 working
days of the week (Mon-Fri)and not the weekends (Sat, Sun). for example, if today is Tuesday and I have 37 date entries for monday I want to update those 37 entries to the following wednesday (7 working days later). I don't want the updated dates to fall onto a weekend day of the week

I know I should be using the weekday function but am not very good at that end of things.

I was considering just adding 7 days to the SQL but then that counts 7 days which would fall on a weekend but I would not be adding 7 full working days onto todays date at the most I would be only adding five. And I need to add seven full working days.

Hope someone can help
 
You could go with your idea of adding 7 days to the SQL but instead of adding 7, add 9 days, that will then give you seven working days.

Hope this helps,
Phil
 
Take a look at this formula:
SET theDate = theDate + 9 - 2 * (Format(theDate + 9, "w", 2) > 5)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top