View Single Post
  #2 (permalink)  
Old May 14th, 2004, 11:11 AM
happygv happygv is offline
Friend of Wrox
Points: 7,647, Level: 37
Points: 7,647, Level: 37 Points: 7,647, Level: 37 Points: 7,647, Level: 37
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,477
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think you are wanted to retrieve records that are falls in a range of DATEs that's given.

EG:
SELECT RECORDS FROM TABLE
WHERE DATEFIELD BETWEEN StartDate and EndDate

Something like that?

For this it is enough if you have only one DATEFIELD in your database, if I am right.

This is how you got to go about.

Code:
Select * from <TABLENAME>
Where <DATEFIELD> between convert(datetime,'<DATE1>') and convert(datetime,'<DATE2>')
OR

Code:
Select * from <TABLENAME>
Where <DATEFIELD> >= convert(datetime,'<DATE1>') and 
<DATEFIELD> <= convert(datetime,'<DATE2>')
Replace <TABLENAME> with your table name, same way do that for <DATEFIELD>, <DATE1> and <DATE2> with relevant data.

Cheers!


-Vijay G
Reply With Quote