Forum Moderators: open

Message Too Old, No Replies

Problem with date values for Inserting a Date in the table

         

stud3

11:53 am on Mar 8, 2005 (gmt 0)

10+ Year Member



hi,
When I try to add a Date value (Datum) to my table, I have Problems. I have the error: CDate is not declared? here I add the code, which I wrote:

<title>Save Data</title>
<link rel="stylesheet" type="text/css" href="format.css">
</head>

<%
Number= Request.Querystring("Number")
RC_Number= Request.Querystring("RC_Number")
date_Begin = Request.Querystring("day") & "." & Request.Querystring("month") & "." & Request.Querystring("year") & chr(32) & Request.Querystring("hour") & ":" & Request.Querystring("minute") & ":00"
date_Begin=CDate(date_Beginn)
date_End = Request.Querystring("day") & "." & Request.Querystring("month") & "." & Request.Querystring("year") & chr(32) & Request.Querystring("hour") & ":" & Request.Querystring("minute") & ":00"
date_End=CDate(date_End)

RC_Description= Request.Querystring("RC_Description")
Description = Request.Querystring("Description")
Description_plausibel= Request.Querystring("Description_plausibel")

The Date Format I would like to use is this way: 24.10.2005 24:10:00. The User can select Day, Month, Year, Hour and Minute through Dropdowns(Comboboxes).

Does anybody have an idea, what should I do in this case? I will appreciate every Help.
Hätte jemand eine Idee was ich machen soll, um den Fehler zu beheben?

CaseyRyan

7:08 pm on Mar 8, 2005 (gmt 0)

10+ Year Member



I don't know if this is the problem but you have two "n" on the date_Begin variable in this line:

date_Begin=CDate(date_Beginn)

Another cause of this may be that your server side parse thinks it's using a different language and therefore doesn't know what CDate is. For example, if your server is setup to use JScript defaultly, it's not going to know how to evaluate this VBScript. To fix this for this page, you can add this to the top of your page:


<%@LANGUAGE=VBSCRIPT %>

-=casey=-

stud3

10:24 pm on Mar 8, 2005 (gmt 0)

10+ Year Member



hi, thanks for the answer, but it doesn't work, my comments in the code are not accepted and then I have errors, I deleted it and now my form is showed again. But when I click the Button "Insert" I hav the error:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CDate'

Because I must translate my variables from german in english I forgot to delete the "n" at the end of Beginn, that wasn't the error.

CaseyRyan

11:13 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



Before you call CDate(date_Begin), I would use the IsDate() [msdn.microsoft.com] function to determine if date_Begin is a valid date.

I think what may be happening is that the date string (date_Begin) is not valid. You could also visually confirm this by Response.Write(date_Begin) to the screen so you can see what the value is.

sampleCode:


If Not IsDate(date_Begin) Then
Response.Write("date_Begin is invalid: " & date_Begin)
Else
' continue with code...

I would use the same code for date_End as well. Better to be safe, then sorry.

-=casey=-