Click here to Skip to main content
15,923,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how we can search data according to month from database in asp.net c#
Posted

Go for MONTH[^].

id happend_at<br />
-- ----------------<br />
1  2009-01-01 12:08<br />
2  2009-02-01 12:00<br />
3  2009-01-12 09:40<br />
4  2009-01-29 17:55


And let's say you want to execute to find all the records that have a happened_at during the month 2009/01 (January 2009). The SQL query would be:
SQL
SELECT id FROM things
WHERE MONTH(happened_at) = 1 AND YEAR(happened_at) = 2009

<br />
output<br />
id<br />
---<br />
1<br />
3<br />
4


src : stackoverflow[^]
-KR
 
Share this answer
 
Your question is not clear. But from what I understand, you need to have a datetime column in your table from which you want filtered data. Update this column with current time every time you insert or update a record. You will need to use WHERE clause[^] to filter the data. If you need to sort them use ORDER BY clause[^].
Also, Date and Time Data Types and Functions[^] would help you filtering date time data.

If this isn't what you want, you need to update your question and add more detail by selecting 'Improve Question' link below your question.
 
Share this answer
 
v2

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