473,804 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

country code

Hi,

I'm new to DB2.
Is there a way to know the date format of the DB2 instance from a SQL
query?
I guess the date format or the country code is stored in a system
table?
which one?

thanks

Rod

Jan 12 '07 #1
5 4070
webrod wrote:
Hi,

I'm new to DB2.
Is there a way to know the date format of the DB2 instance from a SQL
query?
I guess the date format or the country code is stored in a system
table?
which one?

thanks

Rod
Hi Rod,

you might want to read these docs:

- Supported territory codes and code pages:
http://publib.boulder.ibm.com/infoce...n/r0004565.htm

- Date and time formats by territory code:
http://publib.boulder.ibm.com/infoce...n/r0004572.htm

and this article "Fun with Dates and Times" on the DeveloperWorks site:
http://www-128.ibm.com/developerwork.../0211yip3.html

HTH.

--
Jeroen
Jan 12 '07 #2
webrod wrote:
Hi,

I'm new to DB2.
Is there a way to know the date format of the DB2 instance from a SQL
query?
I guess the date format or the country code is stored in a system
table?
which one?

thanks

Rod
DB2 always stores the date in the same internal format. The way it is
displayed depends on the terrritory code of the client that submits the
SQL Select, but it can be overriden by using the CHAR funciton in the
select statement.

select current_date from sysibm.sysdummy 1
01/12/2007

select CHAR(current_da te, ISO) from sysibm.sysdummy 1
2007-01-12

Jan 12 '07 #3
DB2 always stores the date in the same internal format. The way it is
displayed depends on the terrritory code of the client that submits the
SQL Select, but it can be overriden by using the CHAR funciton in the
select statement.

select current_date from sysibm.sysdummy 1
01/12/2007

select CHAR(current_da te, ISO) from sysibm.sysdummy 1
2007-01-12
thanks for your answer.
I agree but 2 questions:
- what is the internal format? I guess it is yyyymmdd
- how would you do the insert (SQL INSERT) to use the internal format
instead of the local format date? Is there a universal way to do an
insert with a DATE field?

Because when I do this:
select * from MYTABLE where DAT_SES = '20070115'
I get this error message:
General SQL error.
[IBM][CLI Driver][DB2/NT] SQL0180N "The syntax of the representation in
the form of chain of a value date/time is incorrect." SQLSTATE=22007

(I have translated from french, I hope this is correct. Not sure about
the word "chain" maybe STRING is a better translation).

Anyway I need to do this:
select * from MYTABLE where DAT_SES = '01/15/2007'
because, the server has the US format (mm/dd/yyyy).
I am running this query from a DB2 client from a workstation. This
workstation has the french configuration.
So the result is "15/01/2007" (french format is dd/mm/yyyy).

So, to conclude, the server format needs to be used (US forma in my
example), not the internal one nor the client one.
And the result (the display) is the local format (french format in my
configuration) .

The thing is that I do not know the server format. I mean not always.
So I don't see a solution. I don't see how to do my INSERT.
I undertsand how I can display the DATE field witht the CHAR function,
but I don't see a way to do an INSERT if I do not know the server
format which is required..

Could you help me?
Rod

Jan 15 '07 #4
"webrod" <ro************ **@gmail.comwro te in message
news:11******** **************@ 11g2000cwr.goog legroups.com...
thanks for your answer.
I agree but 2 questions:
- what is the internal format? I guess it is yyyymmdd
The internal format is yyyymmdd packed into 4 bytes. (You don't need to
know.)
- how would you do the insert (SQL INSERT) to use the internal format
instead of the local format date? Is there a universal way to do an
insert with a DATE field?
DB2 always understands the ISO format 'YYYY-MM-DD' on an insert or predicate
comparison, regardless of client locale.
Because when I do this:
select * from MYTABLE where DAT_SES = '20070115'
I get this error message:
General SQL error.
[IBM][CLI Driver][DB2/NT] SQL0180N "The syntax of the representation in
the form of chain of a value date/time is incorrect." SQLSTATE=22007
where DAT_SES = '2007-01-15'
(I have translated from french, I hope this is correct. Not sure about
the word "chain" maybe STRING is a better translation).

Anyway I need to do this:
select * from MYTABLE where DAT_SES = '01/15/2007'
because, the server has the US format (mm/dd/yyyy).
I am running this query from a DB2 client from a workstation. This
workstation has the french configuration.
So the result is "15/01/2007" (french format is dd/mm/yyyy).
As mentioned above, use the ISO format avoid ambiguity:
where DAT_SES = '2007-01-15'
So, to conclude, the server format needs to be used (US forma in my
example), not the internal one nor the client one.
No, you can always use '2007-01-15' (this is the ISO format and you should
use it on all inserts and predicates if possible).
And the result (the display) is the local format (french format in my
configuration) .
The thing is that I do not know the server format. I mean not always.
So I don't see a solution. I don't see how to do my INSERT.
When doing inserts and in predicates, always use the ISO format:
where DAT_SES = '2007-01-15'
and DB2 will understand it
I undertsand how I can display the DATE field witht the CHAR function,
but I don't see a way to do an INSERT if I do not know the server
format which is required..

Could you help me?
Always use:
where DAT_SES = '2007-01-15' ('YYYY-MM-DD') in inserts and in predicates
and you do not have to worry about which locale the database or the client
is set to.

When you select data, you will have to worry about the client locale, but
that can be overriden by using

SELECT CHAR(DAT_SES, ISO) to always return the ISO format, or whatever
format you want, regardless of client settings.
Jan 15 '07 #5
thanks you very much for your answer!
You're the best!!

Rod

Jan 16 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
8459
by: abracad | last post by:
Hi Is there any (preferably free) PHP script that will identify the country of a visitor, thus allowing one page to be delivered to those from A, B and C, and another to those from X, Y and Z? Thanks
2
4064
by: Laz | last post by:
Hi, I've not worked with javascript, and after searching could not find example of this type of manipulation. I'm trying to set a variable to the last portion of a domain name. for example, if the URL is http://www.telefonica.es/index.php, I'd like to get the "es" code into a variable. Is there a predefined call for this?
2
3564
by: Zyron | last post by:
Hello! I'm developing a web page that has a goal of providing personal content, which means that all information should be written in their own language. I'm about to finish my Geo targeting system that will identify where the users are coming from based on their IP address, and for this project I would really like to replace the English country list with a list of the country in the local language. I'm been around on
9
2063
by: Dave Brydon | last post by:
Access 2003: I currently apply my Postal/Zip Code Format based off the Country Selected; the way I do it is by checking on the country; using the forms "On Current" event procedure, then I use additional code on my Postal/Zip Code field, using the fields "On Got Focus" event (Code Below) to manipulate the input mask. This procedure works well; however, I now wish to have a longer Value List of countries instead of using "Other", but I...
4
9494
by: Susanne Christe | last post by:
Hi all, I know how to use System.Globalization.RegionInfo, but I have problems to get the Numeric Country Code like this here: http://www.atmajaya.ac.id/Weblinks/KodeNegara.html ISO-3166. Do somebody know how to get them in C#.
7
1924
by: Lloyd Dupont | last post by:
from the IP of the request ?
3
11305
by: bush | last post by:
hi everyone! i want to get the ipaddress,and the country name of a webpage visitor,using asp.Net(C#).if anyone knows about it,plz rply me. thanx in advance.
1
5487
by: suresh_nsnguys | last post by:
Respected sir/madam, In My Application, users can send me an email with some keyword 'XXXX' to our mail server 'XXXX@xxxxx.com'.i am using imap_open() and other imap functions to read that email and auto respond the email. My Issue is, i am receiving some email with country code as email id(say <country code><phonenumber>@<carrier.com> and some without country code as email id <numberphonenumber>@<carrier.com> Is...
3
3917
by: MoroccoIT | last post by:
Greetings - I used this code on the link below to trap IP addresses, it worked very nicely. http://www.scandicweb.com/coldfusion/tutorials/tutorial45.cfm Here is a sample output of my report: (note: I removed the real data in purpose) Tracking_Client_Address: 999.99.99.99 Tracking_Client_Host: www.xyz.com Tracking_Referrer: http://www.xyz.com/myfeedback.cfm?ID=531
5
3944
by: bennever | last post by:
Hi, I plan to use drop down lists to populate team results and will use the standard country/state drop down lists as the base code. The question: how can I populate multiple (5) states from entering one country? Here is the current code which works for one state...however if I add another "State" (class=td100) row identical to the one below neither state field offers the drop down list. <form name="form1" action=""> <table...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.