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)
 query for dateadd week occurence

Author  Topic 

karthikeyan2004k
Starting Member

5 Posts

Posted - 2012-05-16 : 02:05:38
Hi I my Application I am trying a task in ms.sql 2005

like (Ms.Outlook week occurences in calender options)

here if i give End After 8 occurences and Recurrence day as

Sunday,Monday in Appointment Recurrence the EndBy Date automatically

generates, i am trying to calculate this EndBy Date but i am not getting a clear solution,

pls give me a solution to generate a query to calculate this EndBy Date

Thanks in Advance...

karthikeyan.r

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-16 : 07:14:17
I must admit I didn't quite follow your requirement - if you are simply trying to calculate the EndDate which should be 8 weeks from the start date, you can do this:
DECLARE @Weeks INT;
SET @Weeks = 8;
DECLARE @startDate DATETIME;
SET @startDate = '20120514';
SELECT DATEADD(dd,7*@Weeks,@startDate)
If that is not what you are looking for, can you post representative sample input data and the output you would like to see?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-16 : 20:47:55
quote:
Originally posted by karthikeyan2004k

Hi I my Application I am trying a task in ms.sql 2005

like (Ms.Outlook week occurences in calender options)

here if i give End After 8 occurences and Recurrence day as

Sunday,Monday in Appointment Recurrence the EndBy Date automatically

generates, i am trying to calculate this EndBy Date but i am not getting a clear solution,

pls give me a solution to generate a query to calculate this EndBy Date

Thanks in Advance...

karthikeyan.r


sorry but why should you give enddate if you've chosen end after 8 occurances? or was the attempt to replace current option with dynamic end date? can you tell me purpose for that?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -