Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

select * from dbo.anytable where date = ' any date' does not give any data

Posted on 2010-01-07
8
Medium Priority
?
185 Views
Last Modified: 2012-05-08
Hello all,

I am trying to delete data from the table for one date I have date field with date and time both. I am not able to filter the date properly I have tried using all the formats of the date but none of them is not working.

I am not getting any error but no data is being displayed.

Please tell me what mistake I am doing.

Thank you in advance.
Regards,
0
Comment
Question by:dualtech
  • 3
  • 3
  • 2
8 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26205036
two methods

where datefield >='20091011' and datefield< dateadd(dd,1,  '20091011' )

or

where convert(varchar, datecolumn, 112) = '20091011'
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 26205049
>>where convert(varchar, datecolumn, 112) = '20091011'

don't do that...very slow.

where datefield >=cast('20091011' as datetime) and datefield< dateadd(dd,1,  cast('20091011' as datetime))
0
 

Author Comment

by:dualtech
ID: 26205118
I am using sql server 2000 will it work in that or not?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 60

Accepted Solution

by:
chapmandew earned 750 total points
ID: 26205127
Yes, it should.  here is an even better way:

declare @x datetime
set @x = cast('20091011' as datetime)

select * from tablename
where datefield >= @x and
datefield < dateadd(dd, 1, @x)
0
 

Author Comment

by:dualtech
ID: 26205137
No it is not working for me I tried using your query chapmandew but it gives me error. and in what format is 20091011 is written. I am not able to get it.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 26205157
try this:

declare @x datetime
set @x = cast('10/11/2009' as datetime)

select * from tablename
where datefield >= @x and
datefield < dateadd(dd, 1, @x)
0
 

Author Closing Comment

by:dualtech
ID: 31674291
Yes this solution worked for me.. thank you
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26205209
I think thats the same i posted :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Update 21-May-2015: I temporarily removed the source code and the code snippets to make major changes to the program. Regards, Joe A recent question here at Experts Exchange piqued my interest, so I decided to provide a thorough solution and publ…
Update 21-May-2015: I temporarily removed the source code and the code snippets to make major changes to the program. Regards, Joe INTRODUCTION This Article is a follow-up to the Article entitled How To Rename-Move a Batch of PDF Files Based o…
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

577 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