Solved

select between dates microsoft sql / c#

Posted on 2006-11-12
3
285 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 70

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 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