dbTalk Databases Forums  

ISO Week of Year

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss ISO Week of Year in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Geoff Muldoon
 
Posts: n/a

Default ISO Week of Year - 01-20-2009 , 05:43 PM






Hi all,

Oracle 10.2.0.3 on Linux ...

I'm having difficulty with a proc which tries to compare data across years
at a specific point in time.

For a particular input_date and comparison_year, I'm trying to retrieve a
comparison_date based on the day-of-week of the input_date and the
corresponding ISO-week-of-year.

EG:
input_date 08-jan-2009 (Thursday, ISO-week-of-year 2) and comparison_year
2007, I'll get a result of 11-jan-2007 (the Thursday of ISO-week-of-year 2
in that year).

I realise that I have now to deal with where there is no matching date,
for example where the input_date's year might have 53 ISO-weeks and the
comparison_year only 52.

The problem I'm having is working out when ISO-week-of years actually
start.

select to_char(to_date('01-jan-1998', 'dd-mon-yyyy'), 'IW')
from dual -- this is a Thursday
--
01

select to_char(to_date('01-jan-1999', 'dd-mon-yyyy'), 'IW')
from dual -- this is a Friday
--
53

Can anyone help in explaining this?

Geoff M

Reply With Quote
  #2  
Old   
Maxim Demenko
 
Posts: n/a

Default Re: ISO Week of Year - 01-20-2009 , 06:01 PM






Geoff Muldoon schrieb:
Quote:
Hi all,

Oracle 10.2.0.3 on Linux ...

I'm having difficulty with a proc which tries to compare data across years
at a specific point in time.

For a particular input_date and comparison_year, I'm trying to retrieve a
comparison_date based on the day-of-week of the input_date and the
corresponding ISO-week-of-year.

EG:
input_date 08-jan-2009 (Thursday, ISO-week-of-year 2) and comparison_year
2007, I'll get a result of 11-jan-2007 (the Thursday of ISO-week-of-year 2
in that year).

I realise that I have now to deal with where there is no matching date,
for example where the input_date's year might have 53 ISO-weeks and the
comparison_year only 52.

The problem I'm having is working out when ISO-week-of years actually
start.

select to_char(to_date('01-jan-1998', 'dd-mon-yyyy'), 'IW')
from dual -- this is a Thursday
--
01

select to_char(to_date('01-jan-1999', 'dd-mon-yyyy'), 'IW')
from dual -- this is a Friday
--
53

Can anyone help in explaining this?

Geoff M
Does that help?
http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm

Best regards

Maxim


Reply With Quote
  #3  
Old   
Geoff Muldoon
 
Posts: n/a

Default Re: ISO Week of Year - 01-20-2009 , 06:22 PM



Maxim Demenko says...
Quote:
Geoff Muldoon schrieb:

The problem I'm having is working out when ISO-week-of years actually
start.

Does that help?
http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
Maxim,

Many thanks, an excellent resource.

"the first calendar week of a year is that one which includes the first
Thursday of that year" was what I needed.

Now to work out my handlers ...

Geoff M


Reply With Quote
  #4  
Old   
Shakespeare
 
Posts: n/a

Default Re: ISO Week of Year - 01-21-2009 , 01:01 PM



Geoff Muldoon schreef:
Quote:
Maxim Demenko says...
Geoff Muldoon schrieb:

The problem I'm having is working out when ISO-week-of years actually
start.

Does that help?
http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm

Maxim,

Many thanks, an excellent resource.

"the first calendar week of a year is that one which includes the first
Thursday of that year" was what I needed.

Now to work out my handlers ...

Geoff M
Or much simpler: the week with jan 4th is week 1. Not the ISO
definition, but proven to work for the next 4000 years at least

Shakespeare


Reply With Quote
  #5  
Old   
Geoff Muldoon
 
Posts: n/a

Default Re: ISO Week of Year - 01-21-2009 , 04:19 PM



Shakespeare says...
Quote:
Geoff Muldoon schreef:
Maxim Demenko says...
Geoff Muldoon schrieb:

The problem I'm having is working out when ISO-week-of years actually
start.

Does that help?
http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm

Maxim,

Many thanks, an excellent resource.

"the first calendar week of a year is that one which includes the first
Thursday of that year" was what I needed.

Now to work out my handlers ...

Geoff M

Or much simpler: the week with jan 4th is week 1. Not the ISO
definition, but proven to work for the next 4000 years at least
Yes, I've twigged that this is a neat way of selecting a date that is
always in ISO week 1.

Geoff M


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.