The conversion of a char data type to a datetime data type resulted in an out-of-range datetime valu

L

luna

getting this error - i think its because im trying to put english date
format into american date format
(asp to sql server 2000)

im getting the date using
mortsourcedlabel.Text = Date.Today
mortsourcedlabel.Visible = True
mortsourced.Visible = False

which throws the date out (in uk format) to 13/02/2004 - all well and good
but -
im assuming that its going out of range as sql needs 02/13/2004
heh im guessing ive been testing code the past 2 weeks -- and now its the
13th which has now thrown up the error!
how do i change the date format not in the code above (i still need to see
the date in english-UK format on the page) but before the sql statement
(maybe in my stored procedure?)
thanks

mark
 
L

luna

nm i sussed it with :-

Dim msl As String = mortsourcedlabel.Text.ToString ' date
Dim day, month, year As String
If mortsourcedlabel.Text.ToString = "" Then
msl = "01/01/1900"
Else
Dim mydate As Date
mydate = mortsourcedlabel.Text.ToString
day = mydate.Day.ToString
month = mydate.Month.ToString
year = mydate.Year.ToString
msl = month + "/" + day + "/" + year
End If

cheers

mark
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top