If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Date and Timestamp in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-04, 13:41
ThomBFG ThomBFG is offline
Registered User
 
Join Date: Aug 2004
Posts: 5
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
Reply With Quote
  #2 (permalink)  
Old 08-16-04, 13:56
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
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.
Reply With Quote
  #3 (permalink)  
Old 08-17-04, 03:35
AStefan AStefan is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 08-17-04, 11:35
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On