Can I insert date into oracle using addnew and update?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zensunni
    New Member
    • May 2007
    • 101

    Can I insert date into oracle using addnew and update?

    I like to use this method when inserting into a database:

    Code:
    Set Insert = Server.CreateObject("ADODB.Recordset")
    Insert.Open "test", objConn, 1, 3, 2
    Insert.AddNew
    Insert("FIRSTNAME") = "Joe"
    Insert("LASTNAME") = "bob"
    Insert("DATE_BORN") = "10/10/80"
    Insert.Update
    Insert.Close
    t RSInsert = nothing
    However, I don't know how to insert the date, seeing that it's an oracle database. I know it's looking for a specific date object. Does one exist in asp that is compatible with oracle?

    The error message is this:

    Code:
    Provider error '80020005'
    
    Type mismatch.
    
    /<asp_script>.asp, line <line_#>
    Thanks for any help
  • idsanjeev
    New Member
    • Oct 2007
    • 241

    #2
    Hi zensunni
    you should use vbscript function for data type conversion
    w3schools
    Try to insert date with

    Code:
    Insert("DATE_BORN") = cdate("10/10/80")

    Comment

    • DrBunchman
      Recognized Expert Contributor
      • Jan 2008
      • 979

      #3
      I've not tried this but what would happen if you were to wrap the Oracle date function to_date around the date you're trying to insert?

      Dr B

      Comment

      • zensunni
        New Member
        • May 2007
        • 101

        #4
        Ha, DrBunch,

        I've tried this with no avail. This is why I went with the assumption that the record set is looking for an actual date object. But just to make sure we're talking about the same thing, this is what I did:

        Insert("DATEBOR N") = "TO_DATE('1 1/11/08', 'mm/dd/08')"

        Comment

        • vikas251074
          New Member
          • Dec 2007
          • 198

          #5
          Hello

          Try using
          Insert("DATE_BO RN") = to_date("10/10/80",'mm/dd/yy')

          Thanks and regards,
          Vikas

          Comment

          • idsanjeev
            New Member
            • Oct 2007
            • 241

            #6
            after testing my code thats was posted is work fine please try to test this code without insert into table just print it
            Code:
            <%date1="11/10/80"
            response.Write(cdate(date1))
            response.Write(formatdatetime(date1,1))
            %>
            I think oracle date function to_date is only work with oracle insert statements
            regards
            Jha

            Comment

            Working...