Here is my date time format displayed
Dr["DATE"] =========> Jun 27 2014 9:06PM
I want it to display like this one =========> 27.06.2014
Here is my code:
ltrlNotlar.Text = Dr["DATE"].ToString()
How to change first format to the second one?
Thankss
Here is my date time format displayed
Dr["DATE"] =========> Jun 27 2014 9:06PM
I want it to display like this one =========> 27.06.2014
Here is my code:
ltrlNotlar.Text = Dr["DATE"].ToString()
How to change first format to the second one?
Thankss
 
    
    use DateTime to do the conversion for you
var dt = DateTime.Parse(Dr["DATE"].ToString());
ltrlNotlar.Text = dt.ToString("dd.MM.yyyy");
 
    
    If Dr is a DataRow, you can this
ltrlNotlar.Text = dr.Field<DateTime>("DATE").ToString("dd.MM.yyyy");
I like using .Field because it does the casting for you. However this only works if the sql column is a Date or DateTime (or possibly DateTimeOffset). If you are storing your date as a string in the database, this won't work.
If the sql column DATE is nullable, make sure to change the generic argument to DateTime?.
 
    
    you could also use something like this:
Convert.ToDateTime(SomeDateTime).ToString("MM.dd.yyyy");
