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.
| Author |
Topic |
|
anumodhc
Starting Member
13 Posts |
Posted - 2009-07-07 : 09:37:58
|
| HiI have a set of Dates in a date period. Have to get distinct Days like"Su,Mo,Tu,We,Th,Fr,Sa" or like "1,2,3,4,5,6,7" from that.Please help.Thanks in advanceAnumodH |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-07 : 09:45:31
|
use datepart(weekday, [date period])ordatename(weekday, [date period]) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
anumodhc
Starting Member
13 Posts |
Posted - 2009-07-08 : 00:45:29
|
| In my case i have a set of date values like 01/06/2009,01/13/2009,01/20/2009,01/27/2009,02/03/2009,02/10/2009,02/17/2009,02/24/2009.All these dates are Thursdays.I need a function to which i will pass these set of date values, and it should return only "Th" or "5"If more days, then it should return like "Mo,Th".Please helpAnumodH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-08 : 00:51:01
|
the set of date value is in a string ? or table ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
anumodhc
Starting Member
13 Posts |
Posted - 2009-07-08 : 00:59:47
|
| date values are in table. I can make it as a string alsoAnumodH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-08 : 01:04:45
|
it is easier to do in table-- Date value in tableselect left(datename(weekday, datecol), 2) as Weekday_Namefrom tableselect datepart(weekday, datecol) as Weekday_Nofrom table if it is in a CSV string, you need to parse the string, convert then form the CSV again. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
anumodhc
Starting Member
13 Posts |
Posted - 2009-07-08 : 01:07:08
|
| Thanks a lot friendAnumodH |
 |
|
|
|
|
|
|
|