Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Comparing dates with C#

0 views
Skip to first unread message

Nicholas Porter

unread,
Jun 14, 2002, 5:03:06 PM6/14/02
to

In classic ASP you could do a select statement with date comparison in
line with the DateDiff function. How do you do date comparisons with C#?
Is there a good reference to C# like there is on DevGru.com for
VBScript?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bob Hoeppner

unread,
Jun 14, 2002, 8:01:13 PM6/14/02
to
The following sample demonstrates Compare.

//this is the simplest way to create a DateTime
//its constructor has many overloads

DateTime t1 = new DateTime(100);
DateTime t2 = new DateTime(20);

if (DateTime.Compare(t1, t2) > 0) Console.WriteLine("t1 > t2");
if (DateTime.Compare(t1, t2) == 0) Console.WriteLine("t1 == t2");
if (DateTime.Compare(t1, t2) < 0) Console.WriteLine("t1 < t2");

For C# resources, search Google, or try developersdex.com or
csharptoday.com

Regards,
Bob

0 new messages