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 2005 Forums
 Transact-SQL (2005)
 How to calculate bi weekly in sql

Author  Topic 

TMDOSS
Starting Member

33 Posts

Posted - 2008-12-26 : 11:30:52
is there any way i can calculate bi weekly in sql
from ex:
from 1/1/2009 to 12/31/2009
I need to know all the fridays biweekly

ex 1/2/2009, 1/16/2009,1/30/2009

Thanks

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2008-12-26 : 11:59:50
To get all Fridays in '09 in the output of a query, you could do something like this

;with cte as
(
select Date = cast('2009-01-02' as datetime) -- first friday in 09
union all
select dateadd(day,14,Date) from cte
where dateadd(day,14,Date) < '2010-01-01'
)
select Date
from cte
OPTION(MAXRECURSION 0);
Go to Top of Page

TMDOSS
Starting Member

33 Posts

Posted - 2008-12-26 : 12:12:30
Thank you so much... that's great
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-27 : 12:47:21
duplicate?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=116872
Go to Top of Page
   

- Advertisement -