Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.net: Date without time

How do you format the date time to just date?

For example, this is what I retrieved from the database: 12/31/2008 12:00:00 AM, but I just want to show the date and no time.

like image 673
Jack Avatar asked Dec 10 '08 17:12

Jack


People also ask

How do I get only date in Visual Basic?

Either use one of the standard date and time format strings which only specifies the date (e.g. "D" or "d"), or a custom date and time format string which only uses the date parts (e.g. "yyyy/MM/dd"). This works if you want a string result. If you want a date result, see madcolor's response below.

How do I only show a date?

Just format the output ToString("mm/dd/yyyy"); to be able to see exactly what you want.

How do I get today's date in VB net?

To access the current system date as a String , use the DateString property. To get or set the current system time, use the TimeOfDay property.

How do you declare a date variable in VB net?

You must enclose a Date literal within number signs ( # # ). You must specify the date value in the format M/d/yyyy, for example #5/31/1993# , or yyyy-MM-dd, for example #1993-5-31# . You can use slashes when specifying the year first.


1 Answers

Either use one of the standard date and time format strings which only specifies the date (e.g. "D" or "d"), or a custom date and time format string which only uses the date parts (e.g. "yyyy/MM/dd").

like image 90
Jon Skeet Avatar answered Sep 19 '22 19:09

Jon Skeet