473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Getting English Day Name

Hi,
I am currently using DAYOFWEEK function and putting CASE statement to
get english day name. For example:

SELECT
CASE DAYOFWEEK(CURRENT DATE)
WHEN 1 THEN 'SUNDAY'
WHEN 2 THEN 'MONDAY'
WHEN 3 THEN 'TUEDAY'
WHEN 4 THEN 'WEDNESDAY'
WHEN 5 THEN 'THURSDAY'
WHEN 6 THEN 'FRIDAY'
WHEN 7 THEN 'SATURDAY'
END
FROM SYSIBM.SYSDUMMY1

The function DAYNAME is not working (or I am not using it rightly). Is
there any other function that can be used to get the english day name
as string? If DAYNAME can be used, what should be its parameter?

Thanks in advance,
Lalit

Jan 18 '06 #1
11 11661
singlal wrote:
The function DAYNAME is not working (or I am not using it rightly). Is
there any other function that can be used to get the english day name
as string? If DAYNAME can be used, what should be its parameter?


Which version of DB2 you are using?

I don't believe you tried this function at all; just a simple test would give
you correct answer:

D:\Working>db2 values dayname(current date)

1
---------------------------------------------------------------------------
Wednesday

D:\Working>db2 values dayname(current timestamp)

1
---------------------------------------------------------------------------
Wednesday
1 record(s) selected.
Or a quick search for product documentation (available online at:
http://publib.boulder.ibm.com/infoce.../v8//index.jsp)
would reveal that:

DAYNAME scalar function
-DAYNAME--(--expression--)-----------------------------------><


The schema is SYSFUN.

Returns a mixed case character string containing the name of the day (for
example, Friday) for the day portion of the argument based on the locale when
the database was started.

The argument must be a date, timestamp, or a valid character string
representation of a date or timestamp that is neither a CLOB nor a LONG VARCHAR.
In a Unicode database, if a supplied argument is a graphic string, it is first
converted to a character string before the function is executed.

The result of the function is VARCHAR(100). The result can be null; if the
argument is null, the result is the null value.
Jan M. Nelken
Jan 18 '06 #2
Jan M. Nelken wrote:
singlal wrote:
The function DAYNAME is not working (or I am not using it rightly). Is
there any other function that can be used to get the english day name
as string? If DAYNAME can be used, what should be its parameter?


Which version of DB2 you are using?


Good question given that the DAYNAME function already existed in V7 and
probably even much earlier.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 19 '06 #3
I am working with DB2 v 7.1. I am not sure why but DAYNAME is not
working. My query is SELECT DAYNAME(CURRENT TIMESTAMP). Error I am
getting is SQLCODE = -440, ERROR: NO FUNCTION BY THE NAME DAYNAME
HAVING COMPATIBLE ARGUMENTS WAS FOUND IN THE CURRENT PATH.

Jan 19 '06 #4
singlal wrote:
I am working with DB2 v 7.1. I am not sure why but DAYNAME is not
working. My query is SELECT DAYNAME(CURRENT TIMESTAMP). Error I am
getting is SQLCODE = -440, ERROR: NO FUNCTION BY THE NAME DAYNAME
HAVING COMPATIBLE ARGUMENTS WAS FOUND IN THE CURRENT PATH.


So what's the current function path?
Have you changed your operating system's clock at some time?
Can't you move to V8, given that V7 is out of service for over a year (and
V7.1 even longer)?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 19 '06 #5
Moving to V8 is out of my hand. It's an org wide decision that's
pending for a while now.

What do you mean by current function path? How do I find it? The
functions like DAYOFWEEK are working fine.

Jan 19 '06 #6
Here is the blurb on the function path. It is from the v7 infocentre:

Function Path
The concept of function path is central to DB2's resolution of
unqualified references that occur when you do not use the schema-name.
For the use of function path in DDL statements that refer to functions,
refer to the SQL Reference. The function path is an ordered list of
schema names. It provides a set of schemas for resolving unqualified
function references to UDFs and methods as well as UDTs. In cases where
a function reference matches functions in more than one schema in the
path, the order of the schemas in the path is used to resolve this
match. The function path is established by means of the FUNCPATH option
on the precompile and bind commands for static SQL. The function path
is set by the SET CURRENT FUNCTION PATH statement for dynamic SQL. The
function path has the following default value:

"SYSIBM","SYSFUN","<ID>"

This applies to both static and dynamic SQL, where <ID> represents the
current statement authorization ID.

Also, perhaps you can try prefacing the function name with "sysfun.".
If that works you know you have a function path issue.
Regards,
Richard McCutcheon.

Jan 19 '06 #7
Still getting -440 SQLCODE. SELECT SYSFUN.DAYNAME(CURRENT DATE) FROM
SYSIBM.SYSDUMMY1.

My confusion is more because DAYOFWEEK is working without having to
qualify. This function also has schema SYSFUN like DAYNAME.

Jan 19 '06 #8
Have you tried your SQL while qualifying the function with a schema?

ex/ db2 "select sysfun.dayname(current date) from sysibm.sysdummy1"
Also, here is the blurb on function path from the v7 info centre.

Function Path
The concept of function path is central to DB2's resolution of
unqualified references that occur when you do not use the schema-name.
For the use of function path in DDL statements that refer to functions,
refer to the SQL Reference. The function path is an ordered list of
schema names. It provides a set of schemas for resolving unqualified
function references to UDFs and methods as well as UDTs. In cases where
a function reference matches functions in more than one schema in the
path, the order of the schemas in the path is used to resolve this
match. The function path is established by means of the FUNCPATH option
on the precompile and bind commands for static SQL. The function path
is set by the SET CURRENT FUNCTION PATH statement for dynamic SQL. The
function path has the following default value:

"SYSIBM","SYSFUN","<ID>"

This applies to both static and dynamic SQL, where <ID> represents the
current statement authorization ID.
Hope this helps point you in the right direction.

Regards,
Richard McCutcheon.

Jan 19 '06 #9
singlal wrote:
Still getting -440 SQLCODE. SELECT SYSFUN.DAYNAME(CURRENT DATE) FROM
SYSIBM.SYSDUMMY1.

My confusion is more because DAYOFWEEK is working without having to
qualify. This function also has schema SYSFUN like DAYNAME.


Then have a look at the SYSCAT.FUNCTIONS catalog view to see if there is a
DAYNAME function listed. If it isn't, I'd suspect that either (a) the V7
manual is not correct about the existence of the function, or (b) something
is garbled in your database.

And if the function exists in the catalog, check its parameters (I believe
SYSCAT.FUNCTIONPARMS or something like that). It should have two
parameters: one input (ordinal = 1) and one output (ordinal = 0) with the
data types DATE and VARCHAR, respectively. If you find all the catalog
entries, then something in your system is not as it should be, which leads
me back to the question if someone changed the system clock on the machine.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 20 '06 #10
Ian
singlal wrote:
I am working with DB2 v 7.1. I am not sure why but DAYNAME is not
working. My query is SELECT DAYNAME(CURRENT TIMESTAMP). Error I am
getting is SQLCODE = -440, ERROR: NO FUNCTION BY THE NAME DAYNAME
HAVING COMPATIBLE ARGUMENTS WAS FOUND IN THE CURRENT PATH.


Are you on z/OS or Linux/UNIX/Windows? [I ask because I've never
seen distributed messages in ALL CAPS, they're usually in mixed case].

Jan 20 '06 #11
I think Ian is right.
DB2 for z/OS desn't support DAYNAME even newest Version8.
But, UDF written in C/C++ were supplied by DB2. See SQL Reference
Appendix H. Sample user-defined functions.

Jan 21 '06 #12

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

Similar topics

0
by: Bill | last post by:
I created a very simple DB with several forms and tables in chinese version of Access XP running in Chinese Win XP. Now I try to run the same DB in English version of Access XP running in English...
3
by: TeekUS | last post by:
hey ppl, i am currently developing a parsing application my input is a 10MB english text file the parsing works fine however every now and then a non english character appears that messes...
14
by: Gidi | last post by:
Hi, For the last week, i'm looking for a way to make a TextBox always write in English (No matter what the OS default language is). i asked here few times but the answers i got didn't help me. i...
3
by: Karunakararao | last post by:
Hi All DateTime populaing based on regional settings In ASP.NET Application Iam using this Code: Thread.CurrentThread.CurrentCulture =...
2
by: Scott M. Lyon | last post by:
I'm having some strange problems with a VB.NET application that I support. The application currently uses SystemInformation.UserName() and SystemInformation.UserDomainName() to determine who is...
20
by: Shawnk | last post by:
I would like to get the class INSTANCE name (not type name) of an 'object'. I can get the object (l_obj_ref.GetType()) and then get the (l_obj_typ.Name) for the class name. I there any way of...
1
by: jackal_on_work | last post by:
Hi, I have a database and want to store data in Spanish and English. To accompish this: 1. Do i need to create separate tables for both the languages like items_en and items_sp? 2. If I opt...
7
by: The Bicycling Guitarist | last post by:
If I have a foreign word, name or phrase in one of my pages, I use the lang attribute to specify the relevant language, e.g., <span lang="de">Manfred von Richthofen</span>. But what if I want to...
4
by: jeet | last post by:
Plz help me.Problem is that On the first page I display all other user with checkbox and give user option to select only two user which he wants to send message. Tell me please how I'll get those...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.