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 2000 Forums
 Transact-SQL (2000)
 how do i do a date range search (help)

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2002-02-21 : 14:26:31
Hi the following sql statement will give me a month and year. But how do i change that to look for 01 2002 thru 02 2002

select * from due_evals
where datepart(yyyy,ann_due_date) = 2002
and datepart(mm,ann_due_date) = 01




LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2002-02-21 : 14:40:19
select * from due_evals
where datepart(yyyy,ann_due_date) = 2002
and datepart(mm,ann_due_date) in (1,2)



Go to Top of Page

csphard
Posting Yak Master

113 Posts

Posted - 2002-02-21 : 14:43:24
that will work however what if the dates are something like 01 1997 thru 02 2002.

Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2002-02-21 : 14:46:29
Why noth use

select * from due_evals
where ann_due_date between '1/1/1997' and '2/28/2002'

-Chad

Go to Top of Page

csphard
Posting Yak Master

113 Posts

Posted - 2002-02-21 : 16:32:27
In my app they only want the user to input mm/yyyy not mm/dd/yyyy

Go to Top of Page
   

- Advertisement -