How to search data By Yearwise....!!!

Posted by Rock_Monu under Sql Server on 10/28/2013 | Points: 10 | Views : 1967 | Status : [Member] | Replies : 8
i make a windows application in asp.net..in this app i searching data by a yearwise like 2013,2014...!!! first we sending date from date time picker in custom format,,nd how to get data in datagridview ,,by year like 2013 data,2014 data...???
please give proper solution...????




Responses

Posted by: Nismeh on: 10/28/2013 [Member] Starter | Points: 25

Up
0
Down
You need to create query which is like

select * from <table> where <column-name> like '2013%'

I am already using this scenario and its working in my cases.

IT KNOWLEDGE IS APPLIED KNOWLEDGE
So Just Do It

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/28/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Can you share the code part of date time picker selection and DB query of data retrieval from database?

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/28/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
while getting data from database use the following condition

WHERE Year( DateTimeColumnNameInYourDatabase ) = YearFromYourDatePicker

or

WHERE DateTimeColumnNameInYourDatabase = YearFromYourDatePicker + '%'


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/28/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
I think the following link is similar to this
http://www.dotnetfunda.com/forums/show/16592/like-operator-on-date-format

Tell us where exactly you are facing issue....

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rock_Monu on: 10/28/2013 [Member] Starter | Points: 25

Up
0
Down
@Nismesh:bt sir in this solution We Can search Value only 2013 data bt if u select 2014,2015 from combo box then we can not find because we already specify in query 2013 year data..so my side that's not proper solution ..thanku sir..and please give proper solution....!!!!

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/28/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer
http://www.codeproject.com/Questions/354793/Filter-datagridview-using-datetimepicker
http://forums.asp.net/t/1848330.aspx?How+do+I+Filter+by+Date+using+a+Calender+or+DateTime+Picker+

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Samirbhogayta on: 10/28/2013 [Member] Starter | Points: 25

Up
0
Down
hi.. this is your query for getting data monthwise or yearwise

SELECT YEAR(DateColumn) AS [Year],MONTH(DateColumn) AS [Month],COUNT(*) from yourtable Group By YEAR(DateColumn) MONTH(DateColumn)

SAMIR
Sr. Software Engineer

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rock_Monu on: 10/29/2013 [Member] Starter | Points: 25

Up
0
Down
www.google.com

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response