Date Issue

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
 
G

Göran Andersson

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.
 
S

sloan

//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.
 
G

Göran Andersson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
Sean29G025

Latest Threads

Top