Monday, 21 April 2014

To display only date in textbox not time.

When we use date datatype it takes both date and time.
So to display only date in Textbox not time use ToShortDateString().
ToShortDateString() : It Converts the value of the current DateTime object to its equivalent short date string representation.


E.g: DateTime time = DateTime.Now;     
   txtpurdt.Text = time.ToShortDateString();     
   txtpurdt.Text = time.ToString("dd/MM/yyyy");


By using time.ToString("dd/MM/YYYY") it displays our date in dd/mm/yyyy Format.

Thank You...
Happy Coding....

No comments:

Post a Comment