Compare from date and to date

Posted by Raj.Trivedi under C# on 5/12/2013 | Points: 10 | Views : 1399 | Status : [Member] [MVP] | Replies : 1
Hello Team

I have to datetime picker in windows application

1.From date.
2.To Date

i want to check whether the from date is greater than to date when i search records

if yes it should show message from date is greater than to date.

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved



Responses

Posted by: Satyapriyanayak on: 5/12/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Try

private void button1_Click(object sender, EventArgs e)
{
DateTime fromdate = DateTime.Parse(Convert.ToDateTime(dateTimePicker1.Text).ToShortDateString());
DateTime todate = DateTime.Parse(Convert.ToDateTime(dateTimePicker2.Text).ToShortDateString());
if (fromdate > todate)
{
MessageBox.Show("from date is greater than to date");
}
}

If this post helps you mark it as answer
Thanks

Raj.Trivedi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response