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
 General SQL Server Forums
 New to SQL Server Programming
 Help with date equiles in where clause

Author  Topic 

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2012-05-15 : 09:41:59
I am trying to search in a view for everything with a date of 5/4/12 but my search returns no results. I know there is data in there since if I do not put a date constraint I can see the data. What is the best way of searching on a DATETIME column? The code I use now is:

SELECT * FROM viewMimicProviderInquiryRequestsTable
WHERE InitialDateofRequest = '2012-05-04'
ORDER BY InitialDateofRequest


--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-05-15 : 09:46:41
SELECT * FROM viewMimicProviderInquiryRequestsTable
WHERE InitialDateofRequest >= '20120504' AND InitialDateofRequest < '20120505'
ORDER BY InitialDateofRequest


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2012-05-15 : 09:57:10
I take it then you can not use the "=" sign in date lookups?

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-05-15 : 10:00:07
it is a matter of the time part in a datetime column.




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -