Hello.
Thanks in Advance.
I am facing serious problem regarding date format.
When i am fetching my expiry date to the expirydate datetime picker.
It showing the two errors commonly.
1. If i used to show as expirydate.text data in date time picker from dataset
String is not recognized as a valid datetime
2. If i used to show as a expirydate.value data in date time picker from dataset
{System.ArgumentOutOfRangeException: Value of '14/12/2011 00:00:00' is not valid for 'Value'. 'Value' should be between 'MinDate' and 'MaxDate'.
Parameter name: Value
at System.Windows.Forms.DateTimePicker.set_Value(DateTime value)
at NWAFH_HIS.frmPatientRegistration.MainSearchResult()}
MY Code is like this way :
string text = ds.Tables[0].Rows[0]["reg_expiry"].ToString();
DateTime ddate = DateTime.Parse(text, dateFormat);
ExpiryDate.Value = Convert.ToDateTime(ds.Tables[0].Rows[0]["reg_expiry"].ToString());
My Database field is 'reg_expiry' and i used datetime as the format.
And all the data saved as '2016-03-12 00:00:00.000' like this format
I am just retrieving the same data as a datetime
Also i tried with
convert(varchar(10),reg_expiry,103)
and
convert(varchar(10),reg_expiry,101)
And Currenlty my datetime picker property is :
this.ExpiryDate.CustomFormat = "dd/MM/yyyy";
this.ExpiryDate.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ExpiryDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.ExpiryDate.Location = new System.Drawing.Point(7, 125);
this.ExpiryDate.Name = "ExpiryDate";
this.ExpiryDate.Size = new System.Drawing.Size(120, 22);
this.ExpiryDate.TabIndex = 50;
with Maxdate : 12/31/9998 and Mindate : 1/1/1753
I tried lots of options/ possibilities unitl now , But still i cannot fetch the datetime field(expiry) value to the datetime picker. So please help me in this regard.