Quantcast
Channel: How to remove time portion of date in C# in DateTime object only? - Stack Overflow
Viewing all articles
Browse latest Browse all 42

Answer by Naveed Hematmal for How to remove time portion of date in C# in DateTime object only?

$
0
0

Add Date property to the DateTime variable

var dateTime = DateTime.Nowvar onlyDate = dateTime.Date

Or You can use DataType annotation as well.

[DataType(DataType.Date)]public DateTime dateTime {get; set;}

The DataType annotation is inside the System.ComponentModel.DataAnnotations namespace.


Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>