1) any date select from first datetimepicker.
2) then another one date is select from second datetime picker.
my request is: the second datetimepicker selecting date only accept after first date.
how to compare from first date and second date.
EXAMPLE:
i.e) first selected date is 10/10/2011 ok.
then second datetimepicker selecting date accept only after first date i.e 11/10/2011
but can not accept before date that is 09/10/2011.
here's the code:
cnn.cmdOpen(cmdForm);
cmdForm.CommandText = " SELECT attendance.work,attendance.in_, attendance.out_,attendance.weekday,"
+ "attendance.date,employee.Empname,employee.Empno"
+ " FROM employee LEFT JOIN attendance ON employee.biomitricno = attendance.badgeno WHERE date >='" + DtFrom.Value.ToString() + "' AND date <='" + DtTo.Value.ToString() + "'";
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = cmdForm;
DataTable dtble = new DataTable();
da.Fill(dtble);
BindingSource bSource = new BindingSource();
bSource.DataSource = dtble;
dgVMonthly.DataSource = bSource;


Mukesh Kumar TiwariRank #1,773 · 844 reputationPosted Nov 28, 2013, 10:42 PM EST
DateTime date2 = new DateTime(2009, 8, 1, 12, 0, 0);
int result = DateTime.Compare(date1, date2);
string relationship;
if (result < 0)
relationship = "is earlier than";
else if (result == 0) relationship = "is the same time as";
else relationship = "is later than";
Girish Sapariya159 reputationPosted Nov 28, 2013, 11:12 PM EST
You can prompt user to enter second date, which is greater than first date.
For this you can check whether Second date is greater than first, if not then you can ask him to select date greater than first. As it will save your time. This will help you to avoid unnecessary connection to database.
e.g
Alex Calidguid108 reputationPosted Nov 28, 2013, 11:27 PM EST
{ if (DtFrom.Value == DtTo.Value)
{
MessageBox.Show("Please Select Employee name and Valid Dates", "DTR");
}
else if (DtFrom.Value >= DtTo.Value)
{ MessageBox.Show("Please Select Employee name and Valid Dates", "DTR");
}
else
{
cnn.cmdOpen(cmdForm);
cmdForm.CommandText = " SELECT attendance.work,attendance.in_, attendance.out_,attendance.weekday," + "attendance.date,employee.Empname,employee.Empno" + " FROM employee LEFT JOIN attendance ON employee.biomitricno = attendance.badgeno WHERE date >='" + DtFrom.Value.ToString() + "' AND date <='" + DtTo.Value.ToString() + "'";
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = cmdForm;
DataTable dtble = new DataTable();
da.Fill(dtble);
BindingSource bSource = new BindingSource();
bSource.DataSource = dtble;
dgVMonthly.DataSource = bSource;
cmdForm.Dispose();
cnn.cn.Close();
}
}
heres the complate code, the only problem is cannot load the date from 1 to 10 (example: 11/01/2013 to 11/09/2013) from 11 to ..... its working fine
Alex Calidguid108 reputationPosted Nov 28, 2013, 11:33 PM EST
Girish Sapariya159 reputationPosted Nov 29, 2013, 12:35 AM EST
Have u check whether data exist for that date range?
or else check the date format of the database server's date column.
Alex Calidguid108 reputationPosted Nov 29, 2013, 2:43 AM EST