Count Sunday & Saturday between two days (1 Viewer)

kashif.special2005

Registered User.
Local time
Tomorrow, 02:10
Joined
Jan 19, 2011
Messages
19
Hi

I have table named Date and there is three columns Start_Date, End Date and Count_Sunday_Saturday.

I want to count how may Sunday and Saturday between Date1 and Date2.

date1
date2
Except_Sunday_Saturday
1/1/2012
1/25/2012



I am not able to do this.

Please help it is very important.

Thanks & Regards,
Kashif.
 

jzwp22

Access Hobbyist
Local time
Today, 16:40
Joined
Mar 15, 2008
Messages
2,629
The only way that I can think of to do what you want is with a custom function. In the attached database, I have created that function: SatSunCount(). I have also included a query (Query1) that shows how to use it.

As a note, it looks like you want to store the count in the field in your table. As a general rule, calculated values are not stored in tables, but rather calculated on the fly when you need them in queries, forms or reports.
 

Attachments

  • CountDays.zip
    15.6 KB · Views: 505

vbaInet

AWF VIP
Local time
Today, 21:40
Joined
Jan 22, 2010
Messages
26,374
* You can use the WeekDay function on Start_Date and End_Date, e.g.
Code:
Weekday([Start_Date]) IN (1, 7)
* Sum() on this field
* Use the Abs() function to get rid of the minus.

NB: I don't see why you have Count_Sunday_Saturday as a field in your table.
 
Last edited:

Users who are viewing this thread

Top Bottom