Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding week number(1-52) for a given date

680 views
Skip to first unread message

dhina...@msn.com

unread,
Feb 19, 1998, 3:00:00 AM2/19/98
to

Hi,
I would appreciate if some one can tell me whether there is any direct command
to get week number(1 to 52) for a given date in DB2.
Thanks in advance.
regards,
dhinakaran

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading

High Lord Gomer

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

On Thu, 19 Feb 1998 20:49:21 -0600, dhina...@msn.com wrote:

>I would appreciate if some one can tell me whether there is any direct command
>to get week number(1 to 52) for a given date in DB2.

It's not pretty, but...

select (days(YourDateValue) -
days(date(char(char(year(YourDateValue)),4) || '001')) + 7) / 7
from YourTable

...will give you values in the range of 1 to 53 (inclusive). This
approach assumes that week 1 consists of Jan 1 through Jan 7
(inclusive) and that you are not concerned if the year started on a
day other than Sunday.

If you are
concerned...(scribble...scribble...scratch...erase...scribble...
scratch...scribble...erase...)...you shouldn't be. :)

94 KTM 620EXC (Gomer)
96 KX80 (Danny)
97 KX60 (Ricky)
96 50SXR (Ricky)
Thanks to: KORE SportCycles 888-394-KORE, the Carolinas' newest KTM dealer

High Lord Gomer

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

On Fri, 20 Feb 1998 14:53:23 GMT, mny...@mindspring.com (High Lord
Gomer) wrote:

>94 KTM 620EXC (Gomer)
>96 KX80 (Danny)
>97 KX60 (Ricky)
>96 50SXR (Ricky)
>Thanks to: KORE SportCycles 888-394-KORE, the Carolinas' newest KTM dealer

Oops! Sorry, I just realized I was leaving my "normal" sig on from
when I usually post to a motocross related newsgroup. I promise to
clean up my act. :)

Michael Nyland
mny...@mindspring.com

Gert

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

Hi,

In DB2 common server and UDB you can use the week function.
From the clp or script center/command center try something like
"values week('1998-01-31')"

Hope this helps,
Gert

dhina...@msn.com wrote:
>
> Hi,


> I would appreciate if some one can tell me whether there is any direct command
> to get week number(1 to 52) for a given date in DB2.

Karl Dirr

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to
the week function in common server does not give the correct week, at
least not in version 2.1.1 and 2.1.2.
besides the weeks are counted in the american way, i.e. the first/last
week in the year may be devided, the first part (until 31.12.) being
week 52, the second part (from 01.01.) being week 1.

mfg
Karl

0 new messages