473,471 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Regarding DAYOFWEEK function

Greetings,
In DB2, we have dayofweek function that returns a
numeric value for the current day (1 for sunday till 7 for saturday)

Is it possible to alter this function value, i mean 1 for monday till 7
for sunday?

Any help would be appreciated.

TIA

Jan 17 '06 #1
16 8243
pa***************@yahoo.co.in wrote:
Greetings,
In DB2, we have dayofweek function that returns a
numeric value for the current day (1 for sunday till 7 for saturday)

Is it possible to alter this function value, i mean 1 for monday till 7
for sunday?

dayofweek_iso() :-)

--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 17 '06 #2
That was easy :-). How can we set at the instance level. i mean how is
the exact implementation.

Jan 17 '06 #3
pa***************@yahoo.co.in wrote:
That was easy :-). How can we set at the instance level. i mean how is
the exact implementation.

What's so bad about typing _ISO?
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 17 '06 #4
I am not getting. i mean how can i set it through CLP?

Jan 17 '06 #5
pa***************@yahoo.co.in wrote:
I am not getting. i mean how can i set it through CLP?

dayofweek_iso() is a function.
Try this:
VALUES dayofweek_iso(current date)

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 17 '06 #6
Thanks for reply Serge, but I think i was not able to put my question
properly. If i do VALUES dayofweek_iso(current date), i get the numeric
value for the current day.
What i want is , some way through which i can set today(say tue) as the
first day of the week and mon as the last day at an instance level?

Is there a way?

TIA

Jan 18 '06 #7
Ian
pa***************@yahoo.co.in wrote:
Thanks for reply Serge, but I think i was not able to put my question
properly. If i do VALUES dayofweek_iso(current date), i get the numeric
value for the current day.
What i want is , some way through which i can set today(say tue) as the
first day of the week and mon as the last day at an instance level?

Is there a way?


You can't do this at the instance level.
Jan 18 '06 #8
Thanks Ian. Can we do it at database level?

Jan 18 '06 #9
pa***************@yahoo.co.in wrote:
Thanks Ian. Can we do it at database level?


No.

But you could always call the _ISO variation of the function and then decide
in your application which way to go. After all, you will usually convert
the numeric value to some textual name for the day, won't you?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 18 '06 #10
thanks Knut. thanks all

Jan 18 '06 #11
pa***************@yahoo.co.in wrote:
thanks Knut. thanks all

Try this:

CREATE FUNCTION DAYOFWEEK_PANKAJ(dt DATE)
RETURNS SMALLINT
CONTAINS SQL DETERMINISTIC NO EXTERNAL ACTION
RETURN dayofweek_iso(dt - 1 day)

That should give you Tuesday as day one for this new function.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 18 '06 #12
Hi,

I have a quesitons on the DAYOFWEEK function. I am currently using this
function and putting CASE statement to get english day name. The
function DAYNAME is not working. Is there any other function that can
be used to get the english name as string for, say current day?

Thanks in advance,
Lalit

Jan 18 '06 #13
I am not sure how are you trying to use the dayname function.

It worked fine for me on 8.2

bash-2.05b$ db2 "select dayname(current date) from sysibm.sysdummy1"

1

----------------------------------------------------------------------------------------------------
Wednesday
1 record(s) selected.

Jan 19 '06 #14
singlal wrote:
Hi,

I have a quesitons on the DAYOFWEEK function. I am currently using this
function and putting CASE statement to get english day name. The
function DAYNAME is not working. Is there any other function that can
be used to get the english name as string for, say current day?

Thanks in advance,
Lalit

CREATE FUNCTION nameofday(dt DATE)
RETURNS VARCHAR(10)
CONTAINS SQL NO EXTERNALACTION DETERMINISTIC
RETURN
CASE dayofweek_iso(dt)
WHEN 1 THEN 'Monday'
WHEN 2 THEN 'Tuesday'
WHEN 3 THEN 'Wednesday'
WHEN 4 THEN 'Thursday'
WHEN 5 THEN 'Friday'
WHEN 6 THEN 'Saturday'
WHEN 7 THEN 'Sunday'
END

That should do it (untested). Getting acquainted to SQL Functions is
very valuable.. Try it.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 19 '06 #15
I tried SELECT DAYNAME(CURRENT DATE) FROM SYSIBM.SYSDUMMY1 but I am
getting SQLCODE -440. I am using DB2 v 7.1

Jan 19 '06 #16
I guess you cannot run it on 7.1

Here is from one of the 7.2 databases I have..

bash-2.05a$ db2 "select dayname(current date) from sysibm.sysdummy1"

1
----------------------------------------------------------------------------------------------------
Thursday

1 record(s) selected.

bash-2.05a$ db2level
DB21085I Instance "testinst" uses DB2 code release "SQL07028" with
level
identifier "03090105" and informational tokens "DB2 v7.1.0.82",
"s030617" and
"U488490".

So looks like Serge's solution is the way to go for you... which also
sounds like what you already have been doing

Jan 19 '06 #17

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

Similar topics

3
by: Gerben van Loon | last post by:
Hi there, hope someone can help me on this: DateTime.Now.DayOfWeek is always returning the american day names like "Monday, Saturday". Even when my CurrentCulture is set to my localized culture....
4
by: M | last post by:
Hello, I have code like dt.DayOfWeek.ToString(CultureInfo.CurrentCulture) where dt is a DateTime object. I get something like "Sunday", "Monday", etc... while I'm expecting it to be in...
8
by: simon | last post by:
dateTime sellDate; int16 dayOfWeek; dayOfWeek=sellDate.DayOfWeek I would like to set that monday is the first day of a week and not sunday. Any idea? In VB there is a function, where you...
0
by: Harry Haller | last post by:
The context is shown below in the getGames() method. I get errors on these lines: dtGames.Rows = (TimeSpan)dtGames.Rows; dtGames.Rows = (DayOfWeek)dtGames.Rows; because the playDate column...
5
by: What-a-Tool | last post by:
Have a group of dynamically created text boxes in a calendar like grid. At the head of each column, the textbox is to contain the day of the week. Now I am using a Select Case statement to...
5
by: vp | last post by:
Hi all, I have to send a file on 3rd friday of every month. Can you please let me know how to get the 3rd friday on every month using SQL
3
by: Charlie Brown | last post by:
I am trying to cast a string to System.DayOfWeek. Don't even know if this is possible but it would sure save me a lot of headache if it is. Trying... Dim strDay As String = "Wednesday" Dim...
2
by: David P. Donahue | last post by:
Probably a simple question: I have a function that receives as an argument a DateTime value. One of the things I want to do is check to see if it's a weekday. So I do the following (sorry for...
5
by: Brian S. | last post by:
Hi, I am trying to calculate the number of DayOfWeek in a month.. for instance.. this month April I want to know how many tuesdays there are in this month, this year I try to use where intDOW =...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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...
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.