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
 SQL Server Development (2000)
 Record selection based on datetime field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-25 : 08:43:12
Balachandar writes "Hi,
I would like to select the records from a table based on A field say workingdate (datetime). I need to fetch records either for a particular date, or for a date range and so on. For a particular date record selection I used

select *
from table
where
cast(working_date as char(11))=cast(getdate() as char(11))

this works fine. But as the data grows, the search is inefficient and it slows down the application drastically.then i tried the following code
select *
from table
where
working_date between '20010521 00:00:00.000' and
'20010521 23:59:59.997'
with whatever testing done till now, the code gives the correct results.can you
Please weather this will be reliable always
or Please suggest a method to select records based on date in an efficient way (the table has almost 2.7 lakh records.)"
   

- Advertisement -