SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Create Function to find sunday and add that sunday
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ankurkhare.mca
Starting Member

India
1 Posts

Posted - 12/22/2012 :  07:56:23  Show Profile  Reply with Quote
Hi..
I need to create a function that accept parameter as date and number,
add that number in date and find how many Sunday in that between and again add that Sunday in date and give that date .. it will be recursive..

plz proved the logic for that

Thanks

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/22/2012 :  09:18:53  Show Profile  Reply with Quote
I was following what you are asking for until "...it will be recursive". Can you explain with some sample data? You can try using the following:
DATEDIFF(wk,@date1,DATEADD(dd,@number,@date1))

Edited by - sunitabeck on 12/22/2012 09:19:36
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 12/22/2012 :  13:25:32  Show Profile  Reply with Quote
see this to understand logic behind integer arithmetic of dates

http://visakhm.blogspot.in/2012/07/generate-datetime-values-from-integers.html



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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000