DateTime question

G

Guest

I am trying to determine whether one date is greater than the the current
date as in:

private void button1_Click(object sender, System.EventArgs e)
{
dtTarget = 10/10/2006;
if(dtTarget > DateTime.Now)
MessageBox.Show("Do somethig!");
else
MessageBox.Show("Don't do anything");
}

This does not work. Can anyone show how this can be accomplished?
 
W

William Stacey [MVP]

DateTime dtTarget = DateTime.Parse("10/10/2006");
if ( dtTarget > DateTime.Now.Date )
Console.WriteLine("Do something!");
else
Console.WriteLine("Don't do anything");

--
William Stacey [MVP]

|I am trying to determine whether one date is greater than the the current
| date as in:
|
| private void button1_Click(object sender, System.EventArgs e)
| {
| dtTarget = 10/10/2006;
| if(dtTarget > DateTime.Now)
| MessageBox.Show("Do somethig!");
| else
| MessageBox.Show("Don't do anything");
| }
|
| This does not work. Can anyone show how this can be accomplished?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top