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 2008 Forums
 Transact-SQL (2008)
 Create Function to find sunday and add that sunday

Author  Topic 

ankurkhare.mca
Starting Member

1 Post

Posted - 2012-12-22 : 07:56:23
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
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-12-22 : 09:18:53
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))
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-22 : 13:25:32
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
   

- Advertisement -