views:

58

answers:

3

Aside from the GL Support, is there a way to override locale settings with custom values for month and day when using mmm-dd-yyyy, modified spanish examples: Jan = ENE, Aug = AGO, or long dates (mmmm) January = ENERO, August = AGOSTO, or (dddd) Monday = LUNES, Thursday = JUEVES, etc.?

+1  A: 

In Oracle:

SQL> alter session set nls_date_format = 'DAY, DD-MONTH-YYYY'
  2  /

Session altered.


SQL> alter session set nls_language='SPANISH'
  2  /

Session altered.


SQL> select sysdate as today, trunc(sysdate,'YYYY') as nyd from dual
  2  /

TODAY                         NYD
----------------------------- -----------------------------
DOMINGO  , 11-ABRIL     -2010 VIERNES  , 01-ENERO     -2010

SQL>
APC
Hmm, dual, this must be how you can do it in Oracle?
Frank Computer
That's a pretty easy/straight-forward way of doing it. The more I look at Oracle, with its rich superset of SQL functions, the more appealing it looks, including LAST_DAY() for the last date of each month (topic related to my previous questions about "using DATE lookup table").
Frank Computer
Well, Oracle does offer a lot of functionality, but then it ought to, considering the price of the license.
APC
@APC - I understand that Oracle 10g Express and APEX are free distribution. Given that you more or less have a feel for my pawnshop app, would you say that the above combo is sufficiently robust for me to re-write my app with it?.. I also understand it runs off a browser. Back in 1989, I developed some apps with Oracle 6.0.33 (DOS) and 5.2 on UNIX and VAX/VMS. At that time, I felt SQL*PLUS,FORMS with triggers was robust!.. I haven't touched Oracle since then, I'm sure there's alot more to it now.
Frank Computer
A: 

In SQL Server at least, you can use the SET LANGUAGE statement to set the language to one of the languages supported in the list of sys.syslanguages

SET LANGUAGE N'Spanish'

--mmm-dd-yyyy,
Select Left(DateName(mm, GetDate()),3)
    + '-' + Right('0' + Cast(DatePart(dd,GetDate()) As Varchar(2)), 2)
    + '-' + Cast(DatePart(yyyy, GetDate()) As char(4))

Note that there is no native date formatting function that will return the mmm-dd-yyyy format, so you have to build that yourself.

Thomas
Ok, but that SQL-Server spanish locale has pre-set values. Can they be further customized to the examples I gave in my question?
Frank Computer
@Frank Developer - It depends on what you mean. Using the example, I provided, `DateName` will return the full Spanish name for those months. So, January will come out as "Enero", April as "Abril" and so on. There is no function to return the three letter abbreviation unless that abbreviation is simply the first three letters like I have done in my example.
Thomas
@Frank Developer - Is it that you specifically want the abbreviation to be in upper case? What is different about your example from the standard Spanish words for the months?
Thomas
@Thomas;@Jonathan Leffler - What I'm looking for is to return all three letter month abbreviations in Spanish and in Caps: ENE,FEB,MAR,ABR,MAY,JUN,JUL,OCT,NOV,DIC.. so that if say in Informix ISQL perform screens attributes section i would define a field-tag: f000 = pawns.pa_pawn_date,format="MMM-DD-YYYY;so that when the user types 01012010 into f000, it gets converted to ENE-01-2010.
Frank Computer
+1  A: 

There are a number of ways to do it in Informix, but most of them work through the GLS facilities. Your question does not make it clear what your scenario is; there could be different answers depending on what you are attempting to do. Scenarios I can see include:

  1. You have a system setup with, say, CLIENT_LOCALE=en_us.8859-15 but you want to see dates formatted as if CLIENT_LOCALE=es_es.8859-15 is in effect.
  2. You have the Spanish setting in effect but you don't like the values it provides and want to use alternative names
  3. You have the Spanish setting in effect but you want to see dates formatted differently from the default format.

Another important factor in the equation is whether DB_LOCALE is set the same as client locale.

Also, you should identify what you are using as the client API - again, there could be different answers depending on what you are using, and also how you are handling dates via the API (you get different results if you ask the API to return a DATE as a string rather than as a native 4-byte signed integer, for example; in the first case, the client API code will do a conversion to string automatically; in the second, your application code can use client API functions to format the value under your control).

IDS has an extensive set of functions to handle the formatting of DATE values. These include:

  • DATE
  • TODAY
  • MDY
  • DAY
  • MONTH
  • YEAR
  • WEEKDAY
  • TO_CHAR
  • TO_DATE
  • ADD_MONTHS
Jonathan Leffler
@Jonathan Leffler - SE,ISQL 7.3,Linux: Numbers 2 and 3 are what I need. ;What I'm looking for is to return all three letter month abbreviations in Spanish, in Caps, DBDATE=MDY4-; ENE,FEB,MAR,ABR,MAY,JUN,JUL,AGO,SEP,OCT,NOV,DIC.. so that if say in Informix ISQL perform screens attributes section i would define a field-tag: f000 = pawns.pa_pawn_date,format="MMM-DD-YYYY; so that when the user types 01012010 into f000, it gets converted to ENE-01-2010.
Frank Computer