0

I have a field named 'CreatedDate' in table.It contain value as 2009-12-07 11:02:20.890.My search parameter is createddate.Parameter contains value as 2009-12-07.My parameter contains only datepart.If my parameter contains only 2009-12-07 its not giving result.Only when time is included its giving result. My query is Select * from STD_Enquiry where CreatedDate='2009-12-07 Can anybody give approppriate query to get the result?

user42348
  • 4,181
  • 28
  • 69
  • 98

4 Answers4

5

Compare only on the date portion (without time):

WHERE DateColumn >= DATEADD(day, DATEDIFF(day, 0, @SomeDateParam), 0)
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
0

Try this:

Select * from STD_Enquiry where CreatedDate like '2009-12-07%'
Dumb Guy
  • 3,336
  • 21
  • 23
0

Use this query to comapare only date

Select * from STD_Enquiry where to_char(CreatedDate,'mmddyyyy') = '09102007'
Vijay
  • 65,327
  • 90
  • 227
  • 319
0

Select * from Table where CreatedDate= ''Datepart(yyyy, CreatedDate) + '-' + Datepart(mm,CreatedDate) + '-' + Datepart(DD,CreatedDate)''

MSH
  • 11
  • 1