Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i try same Method but Not Succeed
in i have same data
Date  ----------  Name
01/03/2020  ----  mr.x
05/03/2020   ---- my.y
01/04/2020   ---- mr.z


What I have tried:

i try this String
C#
string DataLoad = "select month(Date) as Months, count(Name)as Count from customer GROUP BY month(Date)  ";

it's Work Fine and show data
data show like this
Months -- Count
03   ---- 2
04   ---- 1

But i want in my DataGridView Data Show
Month/Year -- Count
03/2020  ---- 2
04/2020  ---- 1
Posted
Updated 30-May-20 22:54pm
v3

1 solution

You could try
C#
string DataLoad = "SELECT Format([Date], \"mm/yyyy\") AS \"Month/Year\", Count([Name]) AS \"Count\" FROM [customer] GROUP BY Format([Date], \"mm/yyyy\")";
 
Share this answer
 
v3
Comments
Amar chand123 31-May-20 4:27am    
not Working
phil.o 31-May-20 4:33am    
Would you mind explaining what that means exactly? What result do you get?
Amar chand123 31-May-20 4:38am    
DataGridView Show Nothing Without any Error

i use access database

And i Use this for save date in DataBase
cmd.Parameters.AddWithValue("@Date", dateTimePicker1.Value.Date);

and in DataBase Column type is DateTime

if i use my this String

string DataLoad = "select month(Date) as Months, count(Name)as Count from customer GROUP BY month(Date) ";
then data show in dataGridView by Only Group by Months
phil.o 31-May-20 4:43am    
So, you are using access database, but have tagged your question MySQL.
And you wonder why you don't get valid answers?
Amar chand123 31-May-20 4:49am    
sorry i tagged wrong

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