Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BETWEEN Query

Status
Not open for further replies.

grimmy

MIS
Nov 25, 1999
57
FR
I am trying to find a set of results within two dates and I am using the follwing query which is failing:-

select * from Employee where PTW BETWEEN '24/07/2002' AND '24/07/2001'

The error I am getting is:-
The conversion of CHAR to DATETIME resulted in a DATETIME value out of range.

The column has a data type of DateTime and I am using SQL 6.5.

Any help will be much appreciated.
 

try this:


select * from Employee where PTW BETWEEN CAST('24/07/2002' as datetime) AND CAST('24/07/2001' as datetime)



 
or this ...


select * from Employee where PTW BETWEEN Convert(datetime,'7/14/2001') AND Convert(Datetime,'7/24/2002')

Thanks

J. Kusch
 
Hi,

Also Try this.... as the default dateformat for SQL server is mdy.

select * from Employee where PTW BETWEEN '07/24/2002' AND '07/24/2001'.

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top