Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Creating a date field using SQL

I've created a table using SQL with a date field. I've used STRPDM to view the data in the date field and found the dates stored are yyyy-mm-dd. I also checked other files which were created from a DDS file and the format is mm/dd/yyyy. I would appreciate any information on this.

Previously ask question: I am trying to create a table using SQL. I would like the dates to be of the *USA (mm/dd/yyyy) format. All of our files have been created with DDS and all of our dates are DATFMT *USA. I would like to create some new files with SQL, but I can't get the dates in the format that we use. How can I do this?

The DATFMT cannot be specified on SQL Create Table. All date values, however, are stored by DB2 in the same internal format regardless of the DATFMT that is specified on the column or field definition. When that data is read from the SQL Table it will be converted to the output date format specified by the application -- in your case the *USA format.

The same answer that was given earlier also applies to your situation with STRPDM. Since STRPDM doesn't allow you to control the date format setting, DB2 displays with the date value on this interface with the default setting. With SQL tables the output default format is always ISO as dictated by the standards -- the default format for the DDS file would be derived from the date format specified in the field definition.


Check out this Search400.com Featured Topic: Database issues resolved

Search400.com's targeted search engine: Get relevant information on DB2/400.

The Best Web Links: Tips, tutorials and more.

Dig Deeper on DB2 UDB (universal databases)