How to truncate a date in .net?

Other than DateTime ctor (new DateTime (year, month, day)), is there any other way to truncate the date?

+3
source share
2 answers

DateTime.Date

Returns only the date component (time is midnight).

+12
source
DateTime.Now.ToShortDateString();

In addition, ToString () is overloaded in DateTime, you can pass several dozen formatting options to it.

See: http://authors.aspalliance.com/aspxtreme/sys/demos/datetimeformats.aspx

+3
source

Source: https://habr.com/ru/post/1698950/


All Articles