DB2-change Date Format

Source: Internet
Author: User
Tags db2 connect db2 connect to


DB2 changes the date format in terms of date representation, which is also a problem I often encounter. The default format for date is determined by the database region code, which is specified when the database is created. For example, if I use territory = US to define the region code when creating a database, the date format will look like the following: values current date www.2cto.com 1 ---------- 1 record (s) selected.
That is to say, the date format is MM/DD/YYYY. to change the format, bind a specific DB2 toolkit. other supported date formats include: DEF uses the date and time formats that match the region code. EUR uses the IBM standard format for European dates and times. ISO uses the date and time formats developed by the International Standards Organization (ISO. JIS uses the Japanese Industrial Standard date and time format. LOC uses the local date and time format that matches the database region code. USA uses the IBM standard format for date and time in the United States.
In Windows, to convert the default date and time format to ISO format (YYYY-MM-DD), perform the following operations: 1. In the command line, change the current directory to sqllib \ bnd. For example, in Windows: c: \ program files \ IBM \ sqllib \ bnd in UNIX:/home/db2inst1/sqllib/bnd 2. from the command line interface of the operating system, use a user with SYSADM permission to connect to the database: db2 connect to DBNAME www.2cto.com db2 bind @ db2ubind. lst datetime ISO blocking all grant public (in your actual environment, replace DBNAME and ISO with your database name and the date format you want to use .) Now, you can see that your database has used ISO as the date format: values current date 1 ---------- 1 record (s) selected. in Windows, convert the default date and time format to ISO format (YYYY-MM-DD), date (char (date ("2008/12/12 19:22:38"), iso )) db2 select char (current date, DEF) from org db2 select char (current date, EUR) from org db2 select char (current date, ISO) from org db2 select char (current date, JIS) from org db2 select char (current date, LOC) from org db2 select char (current date, USA) from org author ITPUByuanqingyu0123

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.