Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DEFAULT comand for DATE instead of DATETIME ?

Status
Not open for further replies.

Sudmill

Programmer
Apr 20, 2001
65
GB
Hi,

I am perfoming a conversion of SQL Server database to DB2. The IBM porting document Im using suggests that I should use the TIMESTAMP datatype (for a SQLServer DATETIME datatype).

The problem is the front end Access application doesnot specify dates in the required format e.g.;

2003-09-14-00.00.00.000000

This means that I will need to use the DATE datatype, which will hopefully work with the front end without any changes.

The DEFAULT option for TIMESTAMP is (DEFAULT CURRENT TIMESTAMP) when creating tables. What should I use to automatically insert the DATE into a DATE field?

Sorry if this is dumb question...



Cheers

John (Sudmill)
 
John,

not sure I've followed but is it simply

CURRENT DATE

your after?

Cheers
Greg
 
I found this out yesterday but couldnt get onto Tek-tips site to update my mewbie question.Doh!

Simply by specifying the DEFAULT statement, DB2 will imply a relevant default option without you having to type it out explicitly.

The following is useful information for anyone else who may need it. Obtained from the following URL.


Table 78. Default Values (when no value specified)

Numeric
0
Fixed-length character string
Blanks
Varying-length character string
A string of length 0
Fixed-length graphic string
Double-byte blanks
Varying-length graphic string
A string of length 0
Date
For existing rows, a date corresponding to January 1, 0001. For added rows, the current date.
Time
For existing rows, a time corresponding to 0 hours, 0 minutes, and 0 seconds. For added rows, the current time.
Timestamp
For existing rows, a date corresponding to January 1, 0001, and a time corresponding to 0 hours, 0 minutes, 0 seconds and 0 microseconds. For added rows, the current timestamp.
Binary string (blob)
A string of length 0

Omission of DEFAULT from a column-definition results in the use of the null value as the default for the column.




Cheers

John (Sudmill)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top