Khopkins32
asked on
Determining whether a date falls on a weekend or holiday
Dear Expert,
Is there a way to determine if a date falls on a weekend or holiday using T-SQL. For the holiday scenario, I am trying to do this without creating a holiday table.
Regards,
-K
Is there a way to determine if a date falls on a weekend or holiday using T-SQL. For the holiday scenario, I am trying to do this without creating a holiday table.
Regards,
-K
Are you using SQL 2005? if so you can do this inside a CLR function but you still have to do the logic of calculating the holidays...
ASKER
Unfortunately I am using SQL Server 2000
>> For the holiday scenario, I am trying to do this without creating a holiday table. <<
SQL has no inherent way of knowing which holidays you want to observe. These could vary by company even within the same city.
SQL has no inherent way of knowing which holidays you want to observe. These could vary by company even within the same city.
why is there a restriction on having a holidays table?
ASKER
No there isn't a restriction on having a holiday table. I am actually considering creating a temp table for holidays. I just wasn't sure if that was the best approach.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The holiday table should be a permanent table, too.
> For the holiday scenario, I am trying to do this without creating a holiday table
This is impossible, unless you give the formula to compute the Holidays
SELECT DATENAME(dw,GETDATE()) -- will give you the weekdays,from this u can check whether it falls under the week ends