Results 1 to 4 of 4

Thread: VBScript - Type Mismatch - Date and Time

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    Thumbs down VBScript - Type Mismatch - Date and Time

    I am using VBSCRIPT and ASP. The control I am using is the Date and Time Picker. When I use my INSERT sql statemtn it works fine. I place the value of the dtpicker into a variable like this:

    dim DateEnter, DateEntered2

    DAteEnter = request.form("DtPicker1")
    DateEntered2 = cdate(DateEnter)

    then my INSERT SQL Statement...


    This works if I am submitting from this form, but if I pass the value of the Dtpicker1 and place the value into a hidden text box and then I go like this:

    DateEnter = request.form("hid1")
    DateEntered2 = cdate(DateEnter)

    I get a Type mismatch on the cdate. Why do I get this error is it because the value is no longer a date in the text box, but then again I am trying to convert the value to a date valeu with the cdate. The value of the hid1 is a date and time value does this make a difference? Is there a way to take just the date and omit the time? When I do a response.write ..... it displays the dtpicker value on the screen.

    Any suggestions?

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    If you changed your code to this:

    Code:
    DateEntered2 = cdate(request.form("hid1"))
    Maybe there's some type of conversion taking place by storing it in the first variable.


    Chris
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Whenever I work with the datepicker control, I always format the date myself:

    Code:
    frmSelect.txtDate.Value = CStr(document.frmSelect.DTPicker1.Month) & "/" & CStr(document.frmSelect.DTPicker1.Day) & "/" & CStr(document.frmSelect.DTPicker1.Year)
    Typically, I would put thie code into the form's onSubmit event and it puts this date value into a hidden text field (which it sounds like your doing). But I don't just put it's value there..
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98
    That worked great.... thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width