Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my table I have a field with datetime type. I want to select values from the table that less than a given date. But in table as it contains with the time when I give the date value like createddate <= '03/05/2011' it doesnt give the '03/05/2011' value.
Posted

Make sure there is no time component in the datetime field. I once faced a similar situation and after spending a few hours noticed that my data had a time field and a result was not being selected in my query.
 
Share this answer
 
if you are passing your data from aspx page you can try


 DateTime.MaxValue.ToLongTimeString() property to your datatime variable 


and in Database you can query like 

select * from Table where   CreatedDate < GivenDate    
 
Share this answer
 
try with mm/dd/yyyy format&gt;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900