Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I inserted all the records in the database.

database type as
DOB             datetime
Wedding day     datetime

I have a button view and when I click that button all records should be displayed in the Grid View.

Grid view Button code as follows:
SQL
C#
Sql = "select Name,DOB,Mobileno,Weddingday,Email from BIrthDayWish where Active = 'A' ORDER BY Name";
        Dr = SCon.ReadSql(Sql);
        GridView1.DataSource = Dr;
        GridView1.DataBind();
        GridView1.Visible = true;

output in Grid View as follows
Name        DOB               Mobile no        Wedding day               Email
ram       22/12/1986          9945598565       22/12/2009            ram@gm.com

But I would like the output in the grid view related to DOB and Wedding day date month to be shown as in char (Jan,Feb like that)
DOB           Wedding
22/12/1986    22/12/2009 (I don't want like)

I want it as
DOB           Wedding
22/dec/1986    22/dec/2009 (I want like)

Name        DOB               Mobile no        Wedding day               Email
ram        22/dec/1986        9945598565        22/dec/2009            ram@gm.com

SQL
C#
Sql = "select Name,DOB,Mobileno,Weddingday,Email from BIrthDayWish where Active = 'A' ORDER BY Name"

From my above query how to correct the query and get the output as follows
Name    DOB           Mobile no     Wedding day       Email
ram    22/dec/1986    9945598565     22/dec/2009    ram@gm.com
Posted
Updated 27-Dec-12 3:23am
v3

1 solution

this way...
SQL
SELECT replace(convert(varchar(11), getdate(), 113),' ', '/')

or
SQL
SELECT replace(CONVERT(VARCHAR(11), GETDATE(), 106),' ', '/')

Happy Coding!
:)
 
Share this answer
 
v3

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