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 2008 Forums
 Transact-SQL (2008)
 filter table with date

Author  Topic 

neel.mk
Starting Member

1 Post

Posted - 2011-01-14 : 06:10:07
Hi , All i am working with a sql server 2005 database. I have table containing a field of type datetime and as well as other datatypes also.
now i need to fetch value from the table filtered by the date , that i will give.
but while executing the query , i am not geting any row.
So, how will i do this
i am using the query as

select INTNO from Point_item_master where PointName='ABC' and Date='1/12/2010'
this date will come as a parameter.
please help i need it urgently

Thanks
Neel

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-01-14 : 06:38:06
What format is the date paramater in? does it also have a time stamp?

2010-01-12 03:44:00.000<> 1/12/2010 00:00:00.000 for example. If the parameter is passed on as datetime AND includes a time, that might be the problem.


Does this return results?

select * from Point_item_master where PointName='ABC' and Date>='1/12/2010' and Date <'1/13/2010'








Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-14 : 08:03:54
Also make sure to use unambigious date format
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-ii.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -