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:
hi frnds ,
i have a one column in database like validity (datetime datatype)


C#
SqlCommand cmd = new SqlCommand("select date from salesdetails ", con);
           SqlDataReader dr = cmd.ExecuteReader();
           if (dr.HasRows)
           {
               while (dr.Read())
               {
                   txtvalidity.Text = dr[0].ToString();
               }
           }


but it is binding into textbox like 7/31/2014 12:00:00 AM this format

I need to bind date into textbox in this format (31/7/2014) how to bind guys please help me . .

thanks
teja.
Posted

1 solution

try this.. :)

C#
SqlCommand cmd = new SqlCommand("select select convert(varchar,date,103) as date from salesdetails ", con);
           SqlDataReader dr = cmd.ExecuteReader();
           if (dr.HasRows)
           {
               while (dr.Read())
               {
                   txtvalidity.Text = dr[0].ToString();
               }
           }


for more info.. :)

Convert Datetime to string in many formats[^]
 
Share this answer
 
v2
Comments
u mani 31-Jul-14 5:12am    
Dear Nirav, thank u
Nirav Prabtani 31-Jul-14 5:18am    
If you got solution than mark it as solved.. :)
u mani 31-Jul-14 5:21am    
ok :)
Nirav Prabtani 31-Jul-14 5:27am    
Thank you mani

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