Getting Date or Time only from a DateTime Object

Luke picture Luke · Nov 4, 2010 · Viewed 127.5k times · Source

I have a DateTime instance that has a Date and a Time. How do I extract only the date or only the time?

Answer

Marc Gravell picture Marc Gravell · Nov 4, 2010
var day = value.Date; // a DateTime that will just be whole days
var time = value.TimeOfDay; // a TimeSpan that is the duration into the day