Re: return the correct WW value

From: Geoff Muldoon <geoff.muldoon_at_trap.gmail.com>
Date: Wed, 29 Oct 2008 14:24:53 +1100
Message-ID: <MPG.237282955481b1de9896a9@news.x-privat.org>


<6b3da48e-93a1-488b-b585-076ef793736c_at_t65g2000hsf.googlegroups.com>, says...
> On Oct 29, 10:01 am, Geoff Muldoon <geoff.muld..._at_trap.gmail.com>

> > > I have a problem for retrieving a correct ww. I hit a snag while
> > > testing the serverPerformanceWeekly script.  It seems the
> > > TO_CHAR(<date>,'WW') function is not returning the correct value.  See
> > > sample below for 26-Oct-2008 (last Sunday), 43 was returned instead of
> > > 44. How shud i do?
> >
> > > SQL> select to_char(to_date('20081026','YYYYMMDD'),'WW') from
> > > serverPerformanceWeekly;
> >
> > > TO
> > > --
> > > 43
> >
> > >  SQL> select to_char(sysdate, 'WW') from dual;
> >
> > > 44
> >
> > On what "sysdate" did you run the above to get that result?  On the Monday
> > after you discovered the "error" or actually on the Sunday?  Did you run
> > the above form a client connection?  What's your (client and server)
> > NLS_TERRITORY setting?  Does that setting default the first day of the
> > week as a Sunday or as a Monday?

> I'm trying to research how to return the correct WW value (week starts
> on a Sunday). have you encountered this before in SQL?

Oops, led you up the wrong path there.

I think you're looking for 'IW' (week of year based on ISO standard) rather than 'WW" (week of year calculated on weeks starting on the day of the week defined by whatever January 1st was).

Geoff M Received on Tue Oct 28 2008 - 22:24:53 CDT

Original text of this message