Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

i have a project in which i would like to insert month and year, and search by this, how to implement it and insert in sql server.\


Please suggest about it.

Thanks in advance.
Posted
Comments
vivektiwari97701 26-Nov-12 1:29am    
ur question is not enough to answer explain more....
Munirajant 26-Nov-12 1:37am    
let me know whether you are following n-tier architecture for your project ?

1 solution

One approach would be to store the actual date in your database and then use the DATEPART[^] function to filter your records by month and year.

For example if you want to retrieve all records which have year 2012 and month 11 your where clause would look like this
SQL
WHERE DATEPART(YEAR,[YourDateColumn]) = 2012 AND DATEPART(MONTH,[YourDateColumn]) = 11
 
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