Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 First Working Day

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-17 : 05:19:18
Dear All,

I have to capture first working date of the month and 7th working date of the month.

Please suggest

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-17 : 06:51:25
do you have a calendar table in your database ?

are you using SQL 2000 or 2005/2008 ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-17 : 11:32:17
I have calendar table and i am using 2000
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-17 : 20:43:40
[code]
select min([DATE]) as [1st Working Day], max([DATE]) as [7th Working Day]
from
(
select TOP 7 [DATE]
from calendar
where [DATE] >= '2010-01-01'
and [DATE] <= '2010-01-31'
and datename(weekday, [DATE]) not in ('Sunday', 'Saturday')
order by [DATE]
) d
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-21 : 07:36:26
getting this error
Line 10: Incorrect syntax near ')'.
Go to Top of Page

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-21 : 07:40:46
solved thanks alot
Go to Top of Page
   

- Advertisement -