Sixthsense Sixthsense - 5 months ago 10
Vb.net Question

ToShortDateString is resulting Time also. How to show Date Only?

DateSerial(2015, 5, 1).ToShortDateString


is resulting 01-05-15 12:00:00 AM.

How do I Get it as 01-05-15?

Using it on GridView Control

Answer

Use

date.ToString("dd'-'MM'-'yyyy")

(for explicit format, switch dd and MM according what you wish in first : day or month) or

date.ToString("d") 

(culture dependant).

See here for examples : https://msdn.microsoft.com/en-us/library/zdtaw1bw%28v=vs.110%29.aspx

Comments