Abhimanyu Singh

Abhimanyu Singh

  • NA
  • 116
  • 49k

How to cast or convert the Date time in dd/mm/yyyy

Jan 5 2013 4:08 AM
hey all hiii,

Hello all, i am new in this field and want some halp from all you.
Actually i have fetched the date only from system.But its having format like mm/dd/yy
but i want like that dd/mm/yy

following arethe .cs code:

insert code: 

con.Open();

SqlCommand cmd = new SqlCommand("insert into contact_us (Name,Email_id,Mobile_no,Comments, entry_date ) values('"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox4.Text+"', '"+System.DateTime.Today.ToShortDateString() +"' )",con);

SqlDataReader dr = cmd.ExecuteReader();

con.Close();

for fetching:

        con.Open();

        SqlDataAdapter da = new SqlDataAdapter("select Name as'Name', Email_id as 'Email Id',Mobile_no as 'Mobile No',Comments as 'Comment', CONVERT(VARCHAR(20),entry_date,111) from contact_us", con);

        DataSet ds = new DataSet();

        da.Fill(ds);

        DataTable dt = ds.Tables[0];

        GridView1.DataSource = dt;

        GridView1.DataBind();

        con.Close();





Answers (9)