SELECT EntiyId, Source, LDAP_DN, EntryType, Message, EventTime
FROM dbo.ONT_LDAP_LOG
WHERE (EntryType = 'Error') AND (CONVERT(varchar(10), EventTime,
101) LIKE '%8/22/2006%')
Here is what I would like to work:
SELECT EntiyId, Source, LDAP_DN, EntryType, Message, EventTime
FROM dbo.ONT_LDAP_LOG
WHERE (EntryType = 'Error') AND (CONVERT(varchar(10), EventTime,
101) LIKE '%' & @Date & '%')
Basically, I have a parameter(@Date), but I need a percent sign before
and after since my date string looks like this: 8/22/2006 11:11:34 AM
I have tried everything, i.e %@Date%, '%@Date%' ...
I am assuming it is a simple answer. Also, the convert function is in
there just as part of my attempt to get this running. If it does not
need to be in there, that is fine. I am using this in SQL 2005 with
SQL Reporting Services
Instead of converting the date, try this:
SELECT EntiyId, Source, LDAP_DN, EntryType, Message, EventTime
FROM dbo.ONT_LDAP_LOG
WHERE EntryType = 'Error'
AND DATEDIFF(day, EventTime, @Date) = 0
See
http://realsqlguy.com/serendipity/archives/5-No-Time-For-DATETIME-Values.html
--
Tracy McKibben
MCDBA
http://www.realsqlguy.com
SELECT * FROM dbo.ONT_LDAP_LOG
WHERE (Message LIKE '%sn has change from%') AND EventTime Between
@Start AND @End
I thought that was working fine, but it will only return a result for
8/31/2006 if @Start = 8/30/2006 and @End = 9/01/2006
On the page that I linked to, there is an example of using DATEDIFF and
DATEADD to "remove" the time portion of a DATETIME value. You should be
able to utilize that technique, just be sure to factor in the midnight
cutoff when determining your end date.
SELECT * FROM dbo.ONT_LDAP_LOG
WHERE (Message LIKE '%@SearchString%')
This fails unless I have the hard code the search string within percent
signs, which is useless. Thanks again for all help this far!