| Author |
Topic |
|
gsrikanthreddi
Starting Member
14 Posts |
Posted - 2007-04-15 : 07:04:46
|
| Hi,Iam new to sql server. I want to create a user defined function to get date in a year(starting day of a week-i.e sunday date) when we give week number as argument. can any body help on this issue? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
gsrikanthreddi
Starting Member
14 Posts |
Posted - 2007-04-15 : 09:32:42
|
| Thnx for ur support,But i has not solved my problem yet,My issue is for example,if i give week number say 15the function should return sunday date of the 15th week in the present year.Plz help me. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
gsrikanthreddi
Starting Member
14 Posts |
Posted - 2007-04-15 : 10:21:07
|
| thank u for ur reply.But i could not get solution.In the links given,date is passes as an argument.but we want week number should be passed as an argument.example if we give 15 as week number then it should display 8-4-2007 .so please giv suitable link |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 10:41:34
|
quote: Originally posted by gsrikanthreddi thank u for ur reply.But i could not get solution.In the links given,date is passes as an argument.but we want week number should be passed as an argument.example if we give 15 as week number then it should display 8-4-2007 .so please giv suitable link
What is your definition of a WEEK ?Your WEEK is starting from which day ?What is the starting date of your week 1 for 2007? KH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 10:42:51
|
Unless your week definition follows ISO WEEK or SQL definition of week no, you will be much better of having your own calendar table which you define your own week no. KH |
 |
|
|
gsrikanthreddi
Starting Member
14 Posts |
Posted - 2007-04-15 : 10:45:24
|
| Hi again,My week starts from sunday through saturday,and my Week 1 starts from 04-01-2007regards'Srikanth |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 10:50:43
|
quote: and my Week 1 starts from 04-01-2007
Please specify your date in YYYY-MM-DD. I have not idea that is Jan 4 or Apr 1. KH |
 |
|
|
gsrikanthreddi
Starting Member
14 Posts |
Posted - 2007-04-15 : 10:53:11
|
| Hi,Sorry i made u confuse,My week 1 starts from 2007-01-04. i.e it is january 4th |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 11:03:49
|
quote: My week starts from sunday through saturday
Jan 4 2007 ? it is a Thursday. Not Sunday ??select datename(weekday, '20070104') KH |
 |
|
|
gsrikanthreddi
Starting Member
14 Posts |
Posted - 2007-04-15 : 11:08:49
|
| Hi,Sorry again,my week 1 starts on 2007-01-07.so if i give week 1 as input then i shud get 2007-01-07thnx & regards,Srikanth |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 11:15:39
|
[code]select dateadd(week, 15 - 1, '2007-01-07')[/code] KH |
 |
|
|
gsrikanthreddi
Starting Member
14 Posts |
Posted - 2007-04-15 : 11:45:10
|
| Hi,I will try this code.Thnx & regardsSrikanth. |
 |
|
|
|