AL MUBARAK

AL MUBARAK

  • NA
  • 96
  • 68.9k

Issue with Year, Month, and Day parameters describe an un-representable DateTime

Jun 18 2012 10:36 AM

Hi,

   i facing the issue with my updating service on reg-start date. when i try to upload the date from date picker in client side, it will not updated in back end. The error shows like "Year, Month, and Day parameters describe an un-representable DateTime ".

Here is my Code :

if (lblRegStart.Text != txtNewRegStart.Text)
            {
                string[] sDate = txtNewRegStart.Text.Split('/');
                DateTime regStartDt = new DateTime(Convert.ToInt16(sDate[2]), Convert.ToInt16(sDate[1]), Convert.ToInt16(sDate[0]), 23, 59, 59);
                if (regStartDt.CompareTo(DateTime.Now) < 0)
                {
                    lblMessage.Text = "The Reg Start date should not be earlier than today";
                    return false;
                }
                string[] sInsDtTo = hidInsDtTo.Value.Split('/');
                if (regStartDt.CompareTo(new DateTime(Convert.ToInt32(sInsDtTo[2].Substring(0, 4)), Convert.ToInt32(sInsDtTo[0]), Convert.ToInt32(sInsDtTo[1]), 23, 59, 59)) > 0)
                {
                    lblMessage.Text = "The Reg Start date should not be later than the date of the Policy Expiry";
                    return false;
                }
                //string sDrFormat = "yyyy-MM-dd";
                //Response.Write(regStartDt.ToString(sDrFormat));
                sResp = adnicService.update_regstart(lblrefno.Text, regStartDt.ToString("mm/dd/yyyy"), ref iErr);
                //sResp = adnicService.update_regstart(lblrefno.Text, regStartDt.ToString(sDrFormat), ref iErr);
                //sResp = adnicService.update_regstart(lblrefno.Text, txtNewRegStart.Text, ref iErr);
                if (iErr != 0)
                {
                    lblMessage.Text = sResp;
                    return false;
                }

}

  Any help will be greatly appreciated. i'm in critical situation.

Thanks in advance.


Answers (2)