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

How to compare to dates Using SQL 2000

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Any one Please help me,
I want to compare DATE1 is less than(or greater than) DATE2 , for that I tried these funtions

1. CONVERT(CHAR(10),DATE1,105) >= CONVERT(CHAR(10),DATE2,105)

2.CONVERT(SMALLDATETIME,DATE1,105) >= CONVERT(SMALLDATETIME,DATE2 ,105)

but these two is not so efficient, Is there anyother function (like Format Function in VB) available in SQL 2000 to compare two dates

Vijay
 
Why can't you just compare them without converting?
Are these dates stored in datetime format?
Andel
andel@barroga.net
 
I agree with Andel regarding the comparison. There is no need to convert to compare datetime columns.

Any time you use a function in a query to perform some action on a column the query will be slower. The reason for this is that SQL cannot utilize indexes. SQL has to scan the table and run the function on every row. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top