Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Checking the date with an IF statement

ITAITA Member Posts: 463
I am using a simple if statement. This is to control stock flow. A user rents something for one year. When this year is completed or a new payment is due a message will be displayed on-screen. The if statement will have a date given to it. It will then check this date against the computer's date. If the date is past the computer's date for example 2003-09-05 is past 2003-07-02 then it will display a message onscreen. Can anyone help make up the condition IF(...)?

Please help. Many Thanks.

ITA :-)

Comments

  • kaennonkaennon Member Posts: 5
    : I am using a simple if statement. This is to control stock flow. A user rents something for one year. When this year is completed or a new payment is due a message will be displayed on-screen. The if statement will have a date given to it. It will then check this date against the computer's date. If the date is past the computer's date for example 2003-09-05 is past 2003-07-02 then it will display a message onscreen. Can anyone help make up the condition IF(...)?
    :
    : Please help. Many Thanks.
    :
    : ITA :-)
    :

    DateTime expiration;
    if(installation)
    {
    expiration = new DateTime(2003, 6 , 14);
    //alternatively:
    //DateTime expiration = DateTime.Now.AddYears(1);
    //memorise the date of installation in a encrypted file or in the registry
    }

    DateTime t = DateTime.Now;
    if(t >= expiration)
    MessageBox.Show("Message", "Title");


Sign In or Register to comment.