July 23, 2007 at 2:55 pm
Quick question. How do I specify my date range to only pull up days Monday - Wednesday?
I am new, i think I should use dateadd()
please help
July 23, 2007 at 2:58 pm
have a look at datepart()
* Noel
July 23, 2007 at 3:05 pm
Can you please include the syntax?
July 23, 2007 at 3:09 pm
select *
from [your table]
where datepart(dw, [yourdatecolumn]) in (1,2,3)
* Noel
July 23, 2007 at 3:19 pm
Thanks Noel
my hero
July 23, 2007 at 3:34 pm
I thought Monday to Wednesday were (2, 3, 4)
N 56°04'39.16"
E 12°55'05.25"
July 24, 2007 at 2:06 am
Not necessarily (could be 4, 5, 6 also)
Since it's depending on the setting of @@DATEFIRST (which may change/be different), the 'safe' way would be:
select ( @@datefirst + datepart(weekday, <supply date here> ) -2 ) %7 + 1
Then no matter of what setting @@DATEFIRST has, monday will aways be 1.
/Kenneth
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply