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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL - Find Fourth Monday, Tuesday .. of given date

Author  Topic 

vavjeeva
Starting Member

1 Post

Posted - 2004-10-07 : 00:48:54
Hi guys,

i need a sql query to find out Fourth Monday, tuesday or... in a Given Date..

i have a query to find out fourth Friday of Given Date

select (28-((Datepart(weekday, DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) ))%7))

For example, If the Date is Oct 2004 ,

the Result is 22

the same way i want to to find out for all other days..

thanks in advance



Jeeva S

dev45
Yak Posting Veteran

54 Posts

Posted - 2004-10-07 : 02:50:46
simple thought
if your query always returns the 4th Friday then
subtracting 1 u get the fourth tue
subtracting 2 u get the foruth wed
and so on...

or u do u want to have a single select statement for all ?
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-10-11 : 18:36:10
>> if your query always returns the 4th Friday then
subtracting 1 u get the fourth tue

Nope - could be +6.
Think I posted something to that would do this recently - not sure if it was on this site though.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-10-11 : 20:04:06
yeah nr... we did this a bit ago.. in the yak corral not less:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=39468

Corey
Go to Top of Page
   

- Advertisement -