Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Checking the date with an IF statement

ITAITA Posts: 463Member
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 Posts: 5Member
    : 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.