Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Oracle, inserting date and time

Oracle, inserting date and time

Scheduled Pinned Locked Moved Database
helpdatabaseoracle
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chris_B84
    wrote on last edited by
    #1

    Hi, I'm fairly new to SQL and am using Oracle SQL Developer. I have a table with a field of data type DATE. (It is the 3rd field along). I need to insert a date and time into the field. I have tried the following: INSERT INTO rentals VALUES (1, 7782, 02/02/2010 09:45:00,'PQ07JHG'); INSERT INTO rentals VALUES (1, 7782, TO_DATE(02/02/2010 09:45:00, 'dd-mm-yyyy' 'hh24:mm:ss'), 'PQ07JHG'); INSERT INTO rentals VALUES (1, 7782, TO_DATE(02/02/2010 09:45:00), 'PQ07JHG'); I keep on getting the same error: Bind variable "45" is NOT DECLARED. Thanks in advance for any help :)

    M 1 Reply Last reply
    0
    • C Chris_B84

      Hi, I'm fairly new to SQL and am using Oracle SQL Developer. I have a table with a field of data type DATE. (It is the 3rd field along). I need to insert a date and time into the field. I have tried the following: INSERT INTO rentals VALUES (1, 7782, 02/02/2010 09:45:00,'PQ07JHG'); INSERT INTO rentals VALUES (1, 7782, TO_DATE(02/02/2010 09:45:00, 'dd-mm-yyyy' 'hh24:mm:ss'), 'PQ07JHG'); INSERT INTO rentals VALUES (1, 7782, TO_DATE(02/02/2010 09:45:00), 'PQ07JHG'); I keep on getting the same error: Bind variable "45" is NOT DECLARED. Thanks in advance for any help :)

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      What tool are you using to insert the data (application you are building or a management tool) it looks like a management tool so try:

      INSERT INTO rentals VALUES (1, 7782, TO_DATE('02/02/2010 09:45:00'), 'PQ07JHG');

      I do believe todate takes a string literal as the first parameter.

      Never underestimate the power of human stupidity RAH

      C 1 Reply Last reply
      0
      • M Mycroft Holmes

        What tool are you using to insert the data (application you are building or a management tool) it looks like a management tool so try:

        INSERT INTO rentals VALUES (1, 7782, TO_DATE('02/02/2010 09:45:00'), 'PQ07JHG');

        I do believe todate takes a string literal as the first parameter.

        Never underestimate the power of human stupidity RAH

        C Offline
        C Offline
        Chris_B84
        wrote on last edited by
        #3

        The software I'm using is Oracle SQL Developer. I tried the above and got the error: "not a valid month". I also tried this (the only different from the original post is that I put '' around them) INSERT INTO rentals VALUES (1, 7782, to_date('02/02/2010 09:45:00', 'dd/mm/yyyy hh24:mm:ss'), 'PQ07JHG'); And with this effort, I got the error: "format code appears twice"

        C 1 Reply Last reply
        0
        • C Chris_B84

          The software I'm using is Oracle SQL Developer. I tried the above and got the error: "not a valid month". I also tried this (the only different from the original post is that I put '' around them) INSERT INTO rentals VALUES (1, 7782, to_date('02/02/2010 09:45:00', 'dd/mm/yyyy hh24:mm:ss'), 'PQ07JHG'); And with this effort, I got the error: "format code appears twice"

          C Offline
          C Offline
          Chris_B84
          wrote on last edited by
          #4

          Aha I found the problem and it works. I put mm for minutes - it should be mi. :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups