Link to home
Start Free TrialLog in
Avatar of Khopkins32
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
Avatar of Aneesh
Aneesh
Flag of Canada image

Khopkins32,
> 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
Avatar of Einstine98
Einstine98

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...
Avatar of Khopkins32

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.
why is there a restriction on having a holidays table?
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
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The holiday table should be a permanent table, too.