Date problems with SQL (previously Access code)

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Date problems with SQL (previously Access code)

    I have the following code:

    biddate = request("close_month") & "/" & request("close_day") & "/" &
    request("close_year")
    bidtime = request("close_time") & " " & request("close_ampm")

    userRS.Fields("bid_date") = biddate & " " & bidtime

    And I'm getting the following error:

    Provider error '80020005'
    Type mismatch.

    I've tried swapping the month and day values, with no luck. I checked
    ASPFAQ.COM, but all the code I found used "INSERT" to insert the record.
    This code is being ported over from using an Access database and if I
    have to change all these records over to using INSERT, it's going to add
    MANY hours to the conversion time and we're past our original deadline
    already.

    Thanks for any help anyone can provide.

    --Dave
    Dave Navarro Guest

  2. Similar Questions and Discussions

    1. Access 2002 PDFWriter VBA Code w/WinXP does not work like Access 2000
      I am trying to print an Access 2002 report (Windows XP OS) as a PDF. I had success with Access 2000 in a Windows 2000 environment, but as soon as I...
    2. Date code
      Dim CurrentDate As Date = Format(Today, "MM/dd/yy") Dim FutureDate As Date = CurrentDate.AddYears(1) What am I doing wrong? I want the...
    3. Problems inserting a date field into Access db
      Hi everybody: When I try to insert a Date field using the Date() function into a field that has a date type in an Access DB I obtain a time value...
    4. Code to put today's date into MM-DD-YY format
      I am new to cgi I would like to place a check box on my form. When it is checked & I run my custom Upload cgi script I would like this code to. ...
    5. Date format - code to alter?
      Hi, I've got an unbound combo box which produces a date in the format "dddd d mm yyyy" eg Monday 4 November 2002. I would like to use this...
  3. #2

    Default Re: Date problems with SQL (previously Access code)

    Well, whoever wrote this code originally should have done it correctly in
    the first place. You really should be rewriting it to use DML SQL instead of
    recordsets, but I understand if you just want to get this running now, and
    hopefully rewrite it later.

    You say you are porting, does that mean you are now going to be using SQL
    Server? I realize that you mention "SQL" in the subject, but Access uses the
    SQL language also. It always helps to specify the database type AND version.
    Granted, the version isn't really relevant here, but it may be in a future
    question, so please get into the habit of telling us both upffront, OK? :-)

    I'm going to assume you meant SQL Server.

    Let's start with some basic debugging: response.write the biddate and
    bidtime variables to make sure they contain what you think they contain.
    Show us the results of the response.writes.

    It's been awhile since I updated a recordset, but I would expect this to
    work (passing the time in 24hr format rather than AM/PM):

    userRS.Fields("bid_date") = #20030630 07:45:00#

    So try getting your expression to result in something that looks the above -
    you may have to use CDate("20030630 07:45:00"). Let us know what works.

    Bob Barrows

    Dave Navarro wrote:
    > I have the following code:
    >
    > biddate = request("close_month") & "/" & request("close_day") & "/" &
    > request("close_year")
    > bidtime = request("close_time") & " " & request("close_ampm")
    >
    > userRS.Fields("bid_date") = biddate & " " & bidtime
    >
    > And I'm getting the following error:
    >
    > Provider error '80020005'
    > Type mismatch.
    >
    > I've tried swapping the month and day values, with no luck. I checked
    > ASPFAQ.COM, but all the code I found used "INSERT" to insert the
    > record. This code is being ported over from using an Access database
    > and if I have to change all these records over to using INSERT, it's
    > going to add MANY hours to the conversion time and we're past our
    > original deadline already.
    >
    > Thanks for any help anyone can provide.
    >
    > --Dave


    Bob Barrows Guest

  4. #3

    Default Re: Date problems with SQL (previously Access code)

    Yes, you're probably right. As I said, it's been a while. The best point you
    made is that a "variant of subtype datetime" is what is needed in this case.

    Bob

    Mads Holm wrote:
    > Bob Barrows wrote:
    >> userRS.Fields("bid_date") = #20030630 07:45:00#
    >>
    >> So try getting your expression to result in something that looks the
    >> above - you may have to use CDate("20030630 07:45:00"). Let us know
    >> what works.
    >
    > It seems to me that the following code:
    >
    > userRS.Fields("bid_date") = TimeSerial(request("close_time"),
    > request("close_ampm"),0 ) _
    > +DateSerial(request("close_year"),
    > request("close_month") ,request("close_day") )
    >
    > would be a better solution as it constructs a variant of subtype
    > datetime in a very controlled manner.
    >
    > Regards
    > Mads Holm

    Bob Barrows Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139