.NET doesn't have a type representing just a date - it's problems like this that made me start Noda Time (which isn't even nearly ready for production yet).
DateTime.Date
returns another DateTime
with the same date as the original, but at midnight. That's basically the closest there is to a Date
type in .NET :( Note that if you want today's date then DateTime.Today
is a simpler way of calling DateTime.Now.Date
.
I've no idea why the compiler is giving an error message that suggests there is a System.Date
type - it doesn't on my machine:
using System;
class Test
{
static void Main()
{
Date today = DateTime.Now.Date;
}
}
Gives this error:
Test.cs(7,9): error CS0246: The type
or namespace name 'Date' could not be
found (are you missing a using
directive or an assembly reference?)
Can you give a similar short but complete program which shows the error message you're getting? Do you have some other library referenced which does have a System.Date
type? (As Tommy Carlier suggests, perhaps System.Dataflow
?)