javascript
Brief description  about Online courses   join in Online courses
View SUMANTA KUMAR SEN 's Profile

COMPARISION BETWEEN DATETIME PICKER AND SYSTEM DATE

CAN ANY ONE TELL ME WHAT IS THE CODE TO COMPARE THE VALUE OF DATE TIME PICKER WITH THE SYSTEM DATE.
Asked by SUMANTA KUMAR SEN | Dec 18, 2010 |  Reply now
Replies (1)
View Dotnet Teacher 's Profile
Hi Sumanta,

The following code example demonstrates how use the Value property to retrieve the current date value. First, the example displays the Value property. The example then increments the Value property by one day and displays the property value again.

public MyClass()
{
// Create a new DateTimePicker
DateTimePicker dateTimePicker1 = new DateTimePicker();
Controls.AddRange(new Control[] {dateTimePicker1});
MessageBox.Show(dateTimePicker1.Value.ToString());

dateTimePicker1.Value = DateTime.Now.AddDays(1);
MessageBox.Show(dateTimePicker1.Value.ToString());
}

Now If you want to compare the value of dateTimePicker to the system date, this can be achieved by the following code

private void dpEndD_Validating(object sender, CancelEventArgs e)
{
if (dateTimePicker1.Value == System.DateTime.Now.Date)
{

MessageBox.Show("Date-Time Picker is correct");
}
}
Dec 28, 2010