November 13, 2003 at 7:42 pm
Hi all,
How to specify where condition to filter date based on range period: Month1 Year1 thru Month2 Year2?
For example to select all rows with date range from June 2002 thru June 2003?
Thanks for any help,
Danny
November 14, 2003 at 1:30 am
You could use something like:
Select aDate from TableA
Where (Month(aDate) >= 5 And Year(aDate) >= 2002)
And ((Month(aDate) <= 5 And Year(aDate) <= 2003)
November 14, 2003 at 7:39 am
Depends on the input format. I prefer to convert input to dates first and then compare. You will have to convert anyway.
set @from = year1 + '-' + month1 + '-01'
set @to = DATEADD(m,1,year2 + '-' + month2 + '-01')
select ...
where [date] >= @from
and [date] < @to
Far away is close at hand in the images of elsewhere.
Anon.
December 5, 2003 at 3:12 am
Hi Sismith and David
Thanks for the help.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply