G
Guest
Hi
I have wrote code to pull a date from a database using a datareader
I keep getting a message that states that..
Cast from string "Null" to type 'Date' is not valid
Does anyone know how i can get rid of this message appearing
What i am trying to do is to retrieve 2 dates from my database. this is ok. I then want to make sure that both dates are not null (i.e a value exists for both dates). If a value exists for both dates i want to find the gap that exists between them in days
If any of the 2 dates are null i want to set the days gap to a value of 400
here is my code...
Dim ToDt As String = (reader1.GetSqlDateTime(0).ToString
Dim DeptDt As String = (reader2.GetSqlDateTime(0).ToString
Dim Gap As Int32
Dim GapArrayList as New ArrayList(
If Not (IsDBNull(ToDt) or IsDBNull(DeptDt)) The
Gap = DateDiff(DateInterval.Day, CDate(DeptDt), CDate(ToDt)
GapArrayList.Add(Gap
Els
GapArrayList.Add(400
End i
MsgBox(Gap
I have wrote code to pull a date from a database using a datareader
I keep getting a message that states that..
Cast from string "Null" to type 'Date' is not valid
Does anyone know how i can get rid of this message appearing
What i am trying to do is to retrieve 2 dates from my database. this is ok. I then want to make sure that both dates are not null (i.e a value exists for both dates). If a value exists for both dates i want to find the gap that exists between them in days
If any of the 2 dates are null i want to set the days gap to a value of 400
here is my code...
Dim ToDt As String = (reader1.GetSqlDateTime(0).ToString
Dim DeptDt As String = (reader2.GetSqlDateTime(0).ToString
Dim Gap As Int32
Dim GapArrayList as New ArrayList(
If Not (IsDBNull(ToDt) or IsDBNull(DeptDt)) The
Gap = DateDiff(DateInterval.Day, CDate(DeptDt), CDate(ToDt)
GapArrayList.Add(Gap
Els
GapArrayList.Add(400
End i
MsgBox(Gap