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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql server 2000 comparing dates 1

Status
Not open for further replies.

tempo1

Programmer
Feb 20, 2007
118
Hi evryone,
I'd like to retrieve all the rows from my table in which the "date time" data type column ("mydatetime") is smaller then 05/03/2007 for example.
i wrote:
Code:
select *
from
mytable
where mydatetime<=05/03/2007
and recieved nothing.
I should get few thousends rows though.
Can anyone show me how to write that correctly ?
Thanks
 
use ISO dates and put quotes around it

select *
from
mytable
where mydatetime<='20070503'

just for fun run this in query analyzer

select 05/03/2007
see what you have is select 3 divided by 5 divided by 2007 which =0 which is 1900/01/01 which is the base date


Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
Google Interview Questions





 
Thanks a lot SQLDenis. You are my saviour..
oh, i ran that query and got 0 again ("select 05/03/2007")....[blush]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top