It would be helpful if you specify the column name that holds a datetime for your table records and at least mention what technique you are using to access the database, e.g. is it "T-SQL", "Stored Procedures", or Maybe it's "Linq-Sql" or seamlessly something else? That way people will give you their correct answer based on their understanding other leaving your question up for guesing, which is exactly what you have done!
Now, below is my guess:
- I assume you have a table called "Comments" and in this table you have a column called "CommentDate"
- I will give the same solution in both T-SQL and Linq-SQL
DateTime endDate = DateTime.Now.AddDays(-1);
String tsqlQuery = "SELECT * FROM Comments c WHERE c.CommentDate <='" + endDate + "';";
SqlCommand cmd = new SqlCommand();
SqlDataReader reader = cmd.ExecuteReader();
while( reader.Read() )
{
}
var comments = (from c in dataContext.Comments
where c.endDate <= endDate
select c).ToList();
foreach(Comment comment in comments)
{
}
That's fairly basic, i don't understand your full requirements and i couldn't expand my solution further than this;
Happy Coding,
Morgs