Solved

select between dates microsoft sql / c#

Posted on 2006-11-12
3
257 Views
Last Modified: 2008-02-01
Cat get this select statement to work:
    string commandStr2 = "Select  *  From [Items] Where [ItemTypeID] = 1 AND ([ItemStartDate] between convert(datetime, '11/12/2004') and convert(datetime,'12/12/2007') )";

the string returns no results...

0
Comment
Question by:mosArt
3 Comments
 
LVL 29

Accepted Solution

by:
Nightman earned 125 total points
ID: 17926646
And if you run the same statement in query analyser?
Also, when using dates in string format, consider passing them in as YYYYMMDD HH:MM:SS - this will consistently work with ALL regional settings as it is ISO comp,iant.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 17926648
Hi mosArt,

have you tried :
    string commandStr2 = "Select  *  From [Items] Where [ItemTypeID] = 1 AND [ItemStartDate] between '2004/11/12' and '2007/12/12'";


Cheers!
0
 
LVL 4

Expert Comment

by:satish_nagdev
ID: 17927531
hi,
can you try following
   string commandStr2 = "Select  *  From [Items] Where [ItemTypeID] = 1 AND (convert(varchar,[ItemStartDate],103) between
convert(varchar, '11/12/2004',103) and convert(varchar,'12/12/2007',103) )";

thanks,
satish
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now