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
 Transact-SQL (2000)
 how to calcualte bi weekly in sql

Author  Topic 

TMDOSS
Starting Member

33 Posts

Posted - 2008-12-26 : 11:30:09
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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-27 : 12:41:16
its possible

SET DATEFIRST 7

DECLARE @StartDate datetime,@StartDay datetime
SET @StartDate = '1/1/2009'
SET @StartDay=DATEADD(dd,6-DATEPART(dw,@StartDate),@StartDate)
SELECT DATEADD(wk,number*2,@StartDay)
FROM master..spt_values
WHERE type='p'
AND DATEADD(wk,number*2,@StartDay)<DATEADD(mm,1,@StartDate)
Go to Top of Page
   

- Advertisement -