Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    5

    Unanswered: Date and Timestamp in DB2

    Hello,

    I've got 2 questions concerning timestamp and date. I need to make an insert in a table where there is one column of type Date and one colum in type Timestamp.
    First I wanted know if the column of type timestamp is automaticaly filled, if not how do I do it?
    Second I don't know the appropriate function for inserting a date (as TO_DATE with Oracle) ?

    Thanks very much for your help, I am really begining with DB2...

    Thom

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    You will have to define the column to have a default value if you intend to 'auto-populate' it ..

    I can't comment on TO_DATE because I am not sure what it does ...

    BTW, please read 'Must read Before Posting' thread ...

    Cheers
    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jun 2004
    Posts
    57

    Cast instead of to_date

    You can use cast instead of to_date.
    It works on sql server, oracle and db2 too.

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by AStefan
    You can use cast instead of to_date.
    It works on sql server, oracle and db2 too.
    You don't need to explicitly cast to DATE; it will happen automatically if you supply a properly formatted string, e.g.
    Code:
    create table test ( mydate date );
    insert into test (mydate) values ('2004-08-17');
    assuming the client uses ISO date format.

Posting Permissions

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