Date Issue

  • Thread starter Thread starter Sonu.NET
  • Start date Start date
S

Sonu.NET

Hello,

I have the following code:
dFromDate = CDate(sBillFromDate) - It works great on my server.

When I publish the project to a diff. server I get the following error:
conversion from string "" to type 'date' is not valid

Not sure how to fix this.
Any help would be great.

Sonu
 
Sonu.NET said:
Hello,

I have the following code:
dFromDate = CDate(sBillFromDate) - It works great on my server.

When I publish the project to a diff. server I get the following error:
conversion from string "" to type 'date' is not valid

Not sure how to fix this.
Any help would be great.

Sonu

You should look for the error earlier in the code. Appearently the
string is empty, and that will never convert correctly into a date.
 
//So the > date is there for sure.//

That is a very stubborn way to look at your problem.


Try

dFromDate = CDate(sBillFromDate)

Catch ex as Exception
Response.Write (string.Format("The value of sBillFromDate is '{0}'" ,
sBillFromDate))
Response.Write ("<br/>")
Response.Write (ex.Message)
Response.Write ("<br/>")
Response.Write (ex.StackTrace)

End Try


There's some very basic errorhandling.


You gonna find you're doing something very simple and basic (and
errant)..............and something to do with your populated (or not
populated value) of sBillFromDate.


PS
Hungarian Notation is very VB6'ish.

dim billFrom as string = "01/01/2009"
dim fromDate as DateTime = Convert.ToDateTime(billFrom)

http://msdn.microsoft.com/en-us/library/system.convert.todatetime.aspx






IndiDeveloper said:
Well it works on my server - and it not working when I publish it. So the
date is there for sure.
 
IndiDeveloper said:
Well it works on my server - and it not working when I publish it. So the
date is there for sure.

No, the date is not there. Look at the error message, it clearly shows
that the string is empty. There is no spoon... eh... date.

As I said, the error is earlier in the code. Look at where the string is
coming from.
 
Back
Top