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;

Alex CalidguidPosted Nov 29, 2013, 7:43 AM
Girish SapariyaPosted Nov 29, 2013, 5:35 AM
Have u check whether data exist for that date range?
or else check the date format of the database server's date column.
Alex CalidguidPosted Nov 29, 2013, 4:33 AM
Alex CalidguidPosted Nov 29, 2013, 4:27 AM
{ 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
Girish SapariyaPosted Nov 29, 2013, 4:12 AM
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
Mukesh Kumar TiwariPosted Nov 29, 2013, 3:42 AM
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";