Solved

sql server 2005 like query does not work for a date

Posted on 2011-03-24
3
446 Views
Last Modified: 2012-08-13
I have a datetime column with a value of 2011-03-03 00:00:00.000

I really don't kow why I could get one row from:
select * from myView where myView.[myDate] = '2011-03-03'

but I can't get anything from:
select * from myView where myView.[myDate] like '%2011-03-03%'

Very appreciated!!!
0
Comment
Question by:jssong2000
3 Comments
 
LVL 6

Expert Comment

by:HyperBPP
ID: 35206977
You are close:

select * from myView where myView.[myDate] like '2011-03-03%'

0
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
ID: 35207001

Do it like this instead

select *
from myView
where myView.[myDate] BETWEEN '2011-03-03'  AND DATEADD(DD, 1, '2011-03-03')
0
 

Author Closing Comment

by:jssong2000
ID: 35207049
Thank you!!!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql help 5 52
upgrade sql 2005 32bit to sql 2008 32 or 64bit on a server 2008 r2 box 6 64
CROSS APPLY 4 51
Query to return total 6 18
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question