dbTalk Databases Forums  

MSACCESS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss MSACCESS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Barbara
 
Posts: n/a

Default MSACCESS - 01-21-2004 , 01:37 PM






I am trying to get business days using datedif function.
I get the difference in days, but do not know how to
account for Saturday and Sunday. Can you help?

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: MSACCESS - 01-21-2004 , 01:57 PM






I presume you want to ask

WHERE day is not Saturday or Sunday?

The best way IMHO to handle this is to have a calendar table.

CREATE TABLE CalendarTable
(
DateID int IDENTITY(1,1) Primary Key,
DateActual small datetime,
DayOfMonth tinyint,
MonthNum tinyint,
YearNum tinyint,
IsHoliday bit,
IsWeekend bit
etc
)

You can therefore count the # of days between two dates where IsWeekend <> 0
and IsHoliday <> 0



--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Barbara" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
I am trying to get business days using datedif function.
I get the difference in days, but do not know how to
account for Saturday and Sunday. Can you help?



Reply With Quote
  #3  
Old   
Darren Green
 
Posts: n/a

Default Re: MSACCESS - 01-21-2004 , 02:01 PM



In message <OBDeygF4DHA.2528 (AT) tk2msftngp13 (DOT) phx.gbl>, Allan Mitchell
<allan (AT) no-spam (DOT) sqldts.com> writes
Quote:
I presume you want to ask

WHERE day is not Saturday or Sunday?

The best way IMHO to handle this is to have a calendar table.

CREATE TABLE CalendarTable
(
DateID int IDENTITY(1,1) Primary Key,
DateActual small datetime,
DayOfMonth tinyint,
MonthNum tinyint,
YearNum tinyint,
IsHoliday bit,
IsWeekend bit
etc
)

You can therefore count the # of days between two dates where IsWeekend <> 0
and IsHoliday <> 0



In support of this method, do a search on Google for something like
public holidays and using the advanced search options filter on your
country TLD. Using this I can find the UK government site that tells me
what the upcoming public holidays are -

http://www.dti.gov.uk/er/bankhol.htm

I find it invaluable it this sort of calculation and also setting
schedules for alerts and similar.


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.