I receintly had to come up with this solution, but I needed the # of business days in a view.  I can't take credit for this, someone else came up with the solution, but this is what you do.  The syntex is going to vary a little depending on your database, but this should work in any database that supports sub selects.
 
my_table - table I want to compute the business day from
date1 date
date2 date
 
non_bus_days - 1 record for every saturday, sunday  and  holiday.
nbd_date date
 
 
to get the business days between date1 and date2, do the following.
 
select date1, date2, (date2 - date1) as num_days, (date2 - date1 - (select count * from non_bus_days where ndb_date between date1 and date2)) as num_bus_days from my_table
 
 
Troy Sosamon
 
 
-----Original Message-----
From: Trevor Green [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 01, 2003 8:50 AM
To: Multiple recipients of list witango-talk
Subject: Witango-Talk: weekdays

Anyone have some efficient code they wish to share which calculates the number of weekdays between two given dates?

 

Trevor Green

 

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/maillist.taf

Reply via email to