If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Santa wants a day off

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-06, 16:34
dansrobe dansrobe is offline
Registered User
 
Join Date: Jan 2004
Posts: 11
Santa wants a day off

Right now, using MS SQL 2k, we use the following query to get "number of business days".

case
when DATEDIFF ( dd , dbo.table_case.creation_time , dbo.table_close_case.close_date )
- DATEDIFF ( wk, dbo.table_case.creation_time , dbo.table_close_case.close_date )*2 <0 then 0
else DATEDIFF ( dd , dbo.table_case.creation_time , dbo.table_close_case.close_date )
- DATEDIFF ( wk, dbo.table_case.creation_time , dbo.table_close_case.close_date )*2
end

It doesn't really do anything except for subtract weekends. But instead of being happy with that, the Boss says "Ok, now pull out holidays as well". Any thoughts on how to approach that?
Reply With Quote
  #2 (permalink)  
Old 01-10-06, 02:11
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
I'd say that this is not easy to implement worldwide, because holidays in your country are probably different than holidays in my country, which are again different from ... etc.

The only way I see (until someone enlightens me) is to create a table which will store holiday dates and include this table into your query, such as

... AND date_column NOT IN (SELECT date_column FROM holiday_table)
Reply With Quote
  #3 (permalink)  
Old 01-10-06, 03:11
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
Ive alwas found the problem with working day calendars is at what level you identify holidays - do you create a personal calendar, where it is different for each employee, or do you use an overall company calendar. do you care about personal holidays, or just national holidays and weekends

A very effective calendar implementation I saw 20+ years ago worked at unit level. effectively it was a flat file which each month represented by 31 x 4 digit values, each value reprsenting that day working day. If it was a holiday or weekend it took the next working day value. it was used for a production control system. so to find when a part should be scheduled you read the 4 digit working day value from the calendar and did what you required

eg
required start date=required date-time to produce
forecastcompletion date=timenow+time left on job + delays
....etc

Becasue we were using flat files (No SQL) we a few other columns to ease locating the correct date using indexed lookups, and also a mechanism for storing a production week
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On