How to delete weekends

  • Thread starter Thread starter csr
  • Start date Start date
I just came accross this at http://www.studenthelp.f2s.com/access3.htm

Forcing a weekday
Limiting the type of data you enter doesn't always require a complex event procedure.

Sometimes the Validation Rule property can limit the type of data you enter. For

instance, if you want a control to accept only weekday values, you can enter the

expression

DatePart("w",[field]) Mod 7 >= 2

as the control's Validation Rule property.

Saturday and Sunday return the integers 0 and 1, respectively. Consequently,

checking for a value that's greater than or equal to 2 eliminates any entry that

equals a 0 or 1. Therefore, the control won't accept any date that falls on a

Saturday or Sunday
 
Wow, a lot of energy used here, but the solution as a query:

For this sample, start with a table called table2 and have two date fields, date1 and date2. Create a query and go to the SQL window. Paste this code and test it.

SELECT Table2.Date1, Table2.Date2, DateDiff("d",[date1],[date2],2) AS DaysDiff, Int([daysdiff]/7) AS Weeks, [daysdiff]-[weeks]*2+IIf(Weekday([date2],2)>5,5-Weekday([date2],2),0)+IIf(Weekday([date1],2)=6,1,0)-IIf(Weekday([date1],2)>Weekday([date2],2),2,0) AS weekdays, RetWeekDays([date1],[date2]) AS ProgNum, Weekday([date2],2) AS tester
FROM Table2;



I tested it and it worked for me ... Let me know how it turns out.

You will have to modify it to your specifications. I included some other fields to see how it progresses.

[This message has been edited by pdx_man (edited 09-25-2001).]
 
Last edited:

Users who are viewing this thread

Back
Top Bottom