// check that it is valid format
// d,m,y
// m,y
// y
if ((nYearFrom != null && nMonthFrom != null && nDayFrom != null ||
nYearFrom != null && nMonthFrom != null ||
nYearFrom != null) &&
(nYearTo != null && nMonthTo != null && nDayTo != null ||
nYearTo != null && nMonthTo != null ||
nYearTo != null))
After a short thinking, this condition can be simplified to:
if (nYearFrom != null && nYearTo != null)