Date Conversion Problem
-
Hi, I am using a Dataset, In which a Date field comes, I am assigning it to a String Variable. After than I am comparing it with Calender1.Selected Date. If CDate(Session("DispDt")) > CType(txtDespDate.Text, Date) Then lblMsg.Text = "Dispatch Date Must be Greater than " & MasterDispDt txtDespDate.Text = "" Exit Sub End If It is giving error as Conversion from string "31-01-2009" to type 'Date' is not valid. Please tell me What can be done. Ramesh Sambari
-
Hi, I am using a Dataset, In which a Date field comes, I am assigning it to a String Variable. After than I am comparing it with Calender1.Selected Date. If CDate(Session("DispDt")) > CType(txtDespDate.Text, Date) Then lblMsg.Text = "Dispatch Date Must be Greater than " & MasterDispDt txtDespDate.Text = "" Exit Sub End If It is giving error as Conversion from string "31-01-2009" to type 'Date' is not valid. Please tell me What can be done. Ramesh Sambari
verify what is coming in your date variable from database?? it will give error only in the case when date string is not valid for example.. sometimes with day instead of 02 comes only 2 when we assign it to a string and datetime conversion fucntion gives error here..... try to give valid date to string.
Government Dyal Singh College Lahore.
-
Hi, I am using a Dataset, In which a Date field comes, I am assigning it to a String Variable. After than I am comparing it with Calender1.Selected Date. If CDate(Session("DispDt")) > CType(txtDespDate.Text, Date) Then lblMsg.Text = "Dispatch Date Must be Greater than " & MasterDispDt txtDespDate.Text = "" Exit Sub End If It is giving error as Conversion from string "31-01-2009" to type 'Date' is not valid. Please tell me What can be done. Ramesh Sambari
-
Hi, I am using a Dataset, In which a Date field comes, I am assigning it to a String Variable. After than I am comparing it with Calender1.Selected Date. If CDate(Session("DispDt")) > CType(txtDespDate.Text, Date) Then lblMsg.Text = "Dispatch Date Must be Greater than " & MasterDispDt txtDespDate.Text = "" Exit Sub End If It is giving error as Conversion from string "31-01-2009" to type 'Date' is not valid. Please tell me What can be done. Ramesh Sambari
Conversion of date depends on your system's date and time setting. Probably computer assumes that 31 is month and 01 is day. Problem may be resolve by interchanging their positions like 01-31-2009, but it may appear when you deploy it to another system. To prevent this error, write your date like 31-Jan-2009, this method will never fails cause the use of month name abbreviation. This is my regular practice and I have got no error since I use it in this format. Try and best of luck.
Be a part of solution, rather then be a part of problem
-
Hi, I am using a Dataset, In which a Date field comes, I am assigning it to a String Variable. After than I am comparing it with Calender1.Selected Date. If CDate(Session("DispDt")) > CType(txtDespDate.Text, Date) Then lblMsg.Text = "Dispatch Date Must be Greater than " & MasterDispDt txtDespDate.Text = "" Exit Sub End If It is giving error as Conversion from string "31-01-2009" to type 'Date' is not valid. Please tell me What can be done. Ramesh Sambari
check the date format