Tuesday, September 4

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

You will get this error because of the datetime Format. You can try like this:-

<asp:TextBox ID="txtdate" runat="server"></asp:TextBox>
                       <cc1:CalendarExtender ID="CalendarDateFrom" runat="server" TargetControlID="txtdate"
                           Format="dd/MM/yyyy">
                       </cc1:CalendarExtender>


//************ To Change the Date format from dd/MM/yyyy to MM/dd/yyyy************//
            string Date_Of_Punch = txtdate.Text;
            System.Globalization.DateTimeFormatInfo datePunch = new System.Globalization.DateTimeFormatInfo();
            datePunch.ShortDatePattern = "dd/MM/yyyy";
            DateTime Punch = Convert.ToDateTime(Date_Of_Punch, datePunch);
//*******pass your date below for inserting
            Attendance.Punch_Date = Punch;
//************ To Change the Date format from dd/MM/yyyy to MM/dd/yyyy************//

Thanks Shibashish Mohanty

No comments:

Post a Comment

Please don't spam, spam comments is not allowed here.

.

ShibashishMnty
shibashish mohanty