Link to home
Start Free TrialLog in
Avatar of mosArt
mosArt

asked on

select between dates microsoft sql / c#

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...

ASKER CERTIFIED SOLUTION
Avatar of Nightman
Nightman
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Éric Moreau
Hi mosArt,

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


Cheers!
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