Re: [U2] [UV] Conversion code for week number

2007-07-22 Thread Anthony W. Youngman
In message <[EMAIL PROTECTED]>, Martin Phillips 
<[EMAIL PROTECTED]> writes

Hi Mark,

The U2 conversion code source code is not public so we can only guess. 
The method used by OpenQM was recently changed to correct problems with 
dates way back in history and is essentially as follows. It sounds 
complex but it is mostly just a series of division operations.


1.  Add 718430 to the day number. This gives a datum of 1 January 0001 
to simplify things. (QM documents that it doesn't support BC dates and 
that we don't allow for the calendar changes in 1752 or 1583 depending 
on where you live).


Or 1919 :-) I always like to point out that 2000 was the first "century 
year" since 1600 when Europe actually agreed whether it was a leap year 
or not.


2. Divide by 146097 to work out how many 400 year cycles we have 
completed. This allows for the complications of leap year calculations.


I'd've thought you could handle the calendar change dead easy here... 
just have a cut-off date (user selectable :-) for the switch between 
calendars, and if it's before that date you apply a constant, while if 
it's after you apply this 400 correction. At the cost of one extra IF, 
you've now got accurate dates right back to start of the modern 
calendar.


Cheers,
Wol
--
Anthony W. Youngman <[EMAIL PROTECTED]>
'Yings, yow graley yin! Suz ae rikt dheu,' said the blue man, taking the
thimble. 'What *is* he?' said Magrat. 'They're gnomes,' said Nanny. The man
lowered the thimble. 'Pictsies!' Carpe Jugulum, Terry Pratchett 1998
Visit the MaVerick web-site -  Open Source Pick
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-22 Thread MAJ Programming
Thanks Martin.

I've heard of several algorhythms similar to this and was curious what Pick
used. Every time I tried my own expressions I either came up short on
covering all dates or it was way too time consuming. Of course I wasn't
writing it in assembler or other lower (faster) code either.

Thanks.
- Original Message -
From: "Martin Phillips" <[EMAIL PROTECTED]>
To: 
Sent: Saturday, July 21, 2007 6:47 PM
Subject: Re: [U2] [UV] Conversion code for week number


> Hi Mark,
>
> The U2 conversion code source code is not public so we can only guess. The
> method used by OpenQM was recently changed to correct problems with dates
> way back in history and is essentially as follows. It sounds complex but
it
> is mostly just a series of division operations.
>
> 1.  Add 718430 to the day number. This gives a datum of 1 January 0001 to
> simplify things. (QM documents that it doesn't support BC dates and that
we
> don't allow for the calendar changes in 1752 or 1583 depending on where
you
> live).
>
> 2. Divide by 146097 to work out how many 400 year cycles we have
completed.
> This allows for the complications of leap year calculations.
>
> 3. Work out how many 100 year cycles we are into the remaining years from
> step 2.
>
> 4. Work out how many 4 year cycles we are into the remaining years from
step
> 3.
>
> 5. Calcualte whole years into the current 4 year cycle.
>
> 6. Decide if this is a leap year.
>
> 7. Work out the calendar date within the year.
>
> 8. Now that we know the day/month/year, apply the conversion code to
> construct the actual date string.
>
> Our date conversions also have codes for 1st, 2nd, 3rd,... style dates and
> for ISO week numbers. The ISO week calculation is even more horrific but
is
> well documented on the web
(http://personal.ecu.edu/mccartyr/ISOwdALG.txt).
>
>
> Martin Phillips
> Ladybridge Systems Ltd
> 17b Coldstream Lane, Hardingstone, Northampton, NN4 6DB
> +44-(0)1604-709200
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-21 Thread Martin Phillips

Hi Mark,

The U2 conversion code source code is not public so we can only guess. The 
method used by OpenQM was recently changed to correct problems with dates 
way back in history and is essentially as follows. It sounds complex but it 
is mostly just a series of division operations.


1.  Add 718430 to the day number. This gives a datum of 1 January 0001 to 
simplify things. (QM documents that it doesn't support BC dates and that we 
don't allow for the calendar changes in 1752 or 1583 depending on where you 
live).


2. Divide by 146097 to work out how many 400 year cycles we have completed. 
This allows for the complications of leap year calculations.


3. Work out how many 100 year cycles we are into the remaining years from 
step 2.


4. Work out how many 4 year cycles we are into the remaining years from step 
3.


5. Calcualte whole years into the current 4 year cycle.

6. Decide if this is a leap year.

7. Work out the calendar date within the year.

8. Now that we know the day/month/year, apply the conversion code to 
construct the actual date string.


Our date conversions also have codes for 1st, 2nd, 3rd,... style dates and 
for ISO week numbers. The ISO week calculation is even more horrific but is 
well documented on the web (http://personal.ecu.edu/mccartyr/ISOwdALG.txt).



Martin Phillips
Ladybridge Systems Ltd
17b Coldstream Lane, Hardingstone, Northampton, NN4 6DB
+44-(0)1604-709200 
---

u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-21 Thread MAJ Programming
None of this explains how 12345 converts to 05/01/2001 (example) (or
vice-versa) as blindingly fast as it always has. We all can write all the
formulas that we want. I want to know what the 'Pick' method is. Unless it
truly is a whole lot of adding and dividing. I thought that was clear in my
original request.

Thanks
Mark Johnson
- Original Message -
From: "Keith Johnson (DSLWN)" <[EMAIL PROTECTED]>
To: 
Sent: Sunday, July 15, 2007 6:16 PM
Subject: Re: [U2] [UV] Conversion code for week number


> Wol wrote
>
> >INT (DAY / 365.25)
> >
> >will always give the correct number of years since day 0.
>
> The following shows that is not strictly true because of the centennial
> non-leap year.
>
> Test Program
> 001:  ZZ = 0
> 002:  FOR XX = 1 TO 5
> 003: Y1 = 1968 + INT((XX-1)/365.25)
> 004: Y2 = OCONV(XX,'DY')
> 005: IF Y1 NE Y2 THEN
> 006:ZZ += 1
> 007:CRT ZZ,XX,OCONV(XX,'D')
> 008: END
> 009:  NEXT XX
>
>
> Results
> 1 48579 01 JAN 2101
> 2 48944 01 JAN 2102
> 3 49309 01 JAN 2103
> 4 49674 01 JAN 2104
>
> I vaguely remember a comment a long time ago (maybe in c.d.p?) that the
> date was chosen _because_ it was a leap year that started on a Sunday
> and that this helped in converting dates from other IBM formats for the
> GIRLS/GIM project.
>
> Regards, Keith
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-18 Thread Mats Carlid

Please disregard and forget what I wrote below.
It just isn't true.

The formula will  fail on some odd dates.
The reason is that the average lenth of a calendar year is not constant
but depends on the year interval used . E.g. 2000-2099 has an average 
year of 365.25

but 2000-2399 has 365.247525

Sorry.

-- mats


Mats Carlid skrev:

A final (?) note on  year calculation shortcuts:

Had Dick chosen jan 1 in a year divisible by 400 as day 1 then

INT(DAY / 365.247525 )

  would have worked all the time.

But selecting a '400-year' starting on a sunday would result in quite
long internal dates unless year 2000 started on a sunday ( it didn't).


365.25 can only work for a limited time as it doesn't observe
the 100 and 400 year rules ...


-- mats
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-17 Thread Mats Carlid

A final (?) note on  year calculation shortcuts:

Had Dick chosen jan 1 in a year divisible by 400 as day 1 then

INT(DAY / 365.247525 )

  would have worked all the time.

But selecting a '400-year' starting on a sunday would result in quite
long internal dates unless year 2000 started on a sunday ( it didn't).


365.25 can only work for a limited time as it doesn't observe
the 100 and 400 year rules ...


-- mats
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-15 Thread Keith Johnson (DSLWN)
Wol wrote

>INT (DAY / 365.25)
>
>will always give the correct number of years since day 0.

The following shows that is not strictly true because of the centennial
non-leap year.

Test Program
001:  ZZ = 0
002:  FOR XX = 1 TO 5
003: Y1 = 1968 + INT((XX-1)/365.25)
004: Y2 = OCONV(XX,'DY')
005: IF Y1 NE Y2 THEN
006:ZZ += 1
007:CRT ZZ,XX,OCONV(XX,'D')
008: END
009:  NEXT XX


Results
1 48579 01 JAN 2101
2 48944 01 JAN 2102
3 49309 01 JAN 2103
4 49674 01 JAN 2104

I vaguely remember a comment a long time ago (maybe in c.d.p?) that the
date was chosen _because_ it was a leap year that started on a Sunday
and that this helped in converting dates from other IBM formats for the
GIRLS/GIM project.

Regards, Keith
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-14 Thread Anthony W. Youngman
In message 
<[EMAIL PROTECTED]>, 
Timothy Snyder <[EMAIL PROTECTED]> writes

I know you said "don't tell me it's the base date", but the date 1/1/68
was chosen for a reason - it means "divide by 365.25" actually gives the
right answer...


Anybody that relies on that in code is bound to get a nasty surprise.
There are dates for which that doesn't work.  Try it with July 7, 2006.
Today's date is 14437, a year ago was 14072.  The difference is 365.
Divide that by 365.25 and you get less than one year.  The argument could
be made that you could round it after the division, but that will throw
other dates off.  The bottom line is that this is not a safe way to
accurately calculate an age - it's *almost* always right, but when that's
not good enough, it shouldn't be used.


Yes, but that's not quite what I was thinking ...

INT (DAY / 365.25)

will always give the correct number of years since day 0. The other 
thing I forgot, was MOD( DAY, 7) gives you the day of the week, too, 
iirc. Any road, day 0 was chosen to make date arithmetic as simple as 
possible.


Cheers,
Wol
--
Anthony W. Youngman <[EMAIL PROTECTED]>
'Yings, yow graley yin! Suz ae rikt dheu,' said the blue man, taking the
thimble. 'What *is* he?' said Magrat. 'They're gnomes,' said Nanny. The man
lowered the thimble. 'Pictsies!' Carpe Jugulum, Terry Pratchett 1998
Visit the MaVerick web-site -  Open Source Pick
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number

2007-07-13 Thread Bob Woodward
What was that Susan?  A 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Susan Joslyn
Sent: Friday, July 13, 2007 8:16 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] [UV] Conversion code for week number

This is silly and a bit off-topic - but I remember the day I found out that
you could perform a date conversion in Universe to get the Chinese year!  I
had so much fun adding "The Year of the Pig" at the top of all the reports
at the customer site where I was working at the time.  I wonder if they are
still seeing that on some of their reports.

---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number

2007-07-13 Thread Brian Leach
Actually that was one of my earliest support calls to VMARK, and AFAIK it still 
ain't fixed..

The Chinese year does not change on the 1st of January...

Brian "Year of the Horse" (or just an old nag)




This is silly and a bit off-topic - but I remember the day I found out that
you could perform a date conversion in Universe to get the Chinese year!  I
had so much fun adding "The Year of the Pig" at the top of all the reports
at the customer site where I was working at the time.  I wonder if they are
still seeing that on some of their reports.

---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number

2007-07-13 Thread Susan Joslyn
This is silly and a bit off-topic - but I remember the day I found out that
you could perform a date conversion in Universe to get the Chinese year!  I
had so much fun adding "The Year of the Pig" at the top of all the reports
at the customer site where I was working at the time.  I wonder if they are
still seeing that on some of their reports.

---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number

2007-07-12 Thread David Jordan
Hi All

This may help to build a function for conv code.

 PRINT "DATE ":
 INPUT DATE
 D = ICONV(DATE,"D2")
 YY = OCONV(D,'D4 Y')
 YEAR.START = ICONV("01 JAN ":YY,"D4") ;* First day of the year
 D = D - YEAR.START+1+MOD(YEAR.START,7);* Use the Mod 7 for calendar week
 PRINT "WEEK ":INT(D/7)+1

Regards

David Jordan
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number

2007-07-12 Thread Jerry Banker
Fairly simple; The iconv opens up a worm hole sends the date information
through to a super computer in the future which cranks out an answer and
sends it back to the iconv a fraction of a second later.

-Original Message-
From: MAJ Programming [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 11, 2007 8:08 PM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] [UV] Conversion code for week number

So we're guessing.

I gotta believe that there's something to it instead of simply counting
days, dividing by 365.25, carrying the 3, square root of October etc.

How does 1/1/68 mean 'divide by 365.25'? Also, divide 'what' by 365.25 ?

Considering how incredibly often the function is used and how blazingly
fast
it does its ICONVs and OCONVs, there must be something more to it.

Thanks
- Original Message -
From: "Timothy Snyder" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, July 11, 2007 12:06 PM
Subject: RE: [U2] [UV] Conversion code for week number


> > I know you said "don't tell me it's the base date", but the date
1/1/68
> > was chosen for a reason - it means "divide by 365.25" actually gives
the
> > right answer...
>
> Anybody that relies on that in code is bound to get a nasty surprise.
> There are dates for which that doesn't work.  Try it with July 7,
2006.
> Today's date is 14437, a year ago was 14072.  The difference is 365.
> Divide that by 365.25 and you get less than one year.  The argument
could
> be made that you could round it after the division, but that will
throw
> other dates off.  The bottom line is that this is not a safe way to
> accurately calculate an age - it's *almost* always right, but when
that's
> not good enough, it shouldn't be used.
>
> Tim Snyder
> Consulting I/T Specialist
> U2 Lab Services
> Information Management, IBM Software Group
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-12 Thread Martin Phillips

Hi all,

Apologies if I am diving in late after this has already been said

Although there are many different interpretations of "week number", the most 
widely used is the ISO week number as printed in many diaries, etc. This was 
discussed in detail a couple of months back either on this list or on CDP, I 
forget which. You should be able to find it in the digests.


We had used a simple algorithm in our business applications for some years 
(and published it in our U2 programming classes) only to find that it 
stopped working a couple of years back. This forced us to do the research 
and find the full algorithm.


We implemented this as a standard conversion code in OpenQM and were 
surprised to find that the algorithm is far from simple, however, it is 
widely available on the web. Simply dividing by 365.25 does not work 
especially when you take into account the possibility of doing the 
calculation on Feb 29.



Martin Phillips
Ladybridge Systems Ltd
17b Coldstream Lane, Hardingstone, Northampton, NN4 6DB
+44-(0)1604-709200 
---

u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-11 Thread MAJ Programming
So we're guessing.

I gotta believe that there's something to it instead of simply counting
days, dividing by 365.25, carrying the 3, square root of October etc.

How does 1/1/68 mean 'divide by 365.25'? Also, divide 'what' by 365.25 ?

Considering how incredibly often the function is used and how blazingly fast
it does its ICONVs and OCONVs, there must be something more to it.

Thanks
- Original Message -
From: "Timothy Snyder" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, July 11, 2007 12:06 PM
Subject: RE: [U2] [UV] Conversion code for week number


> > I know you said "don't tell me it's the base date", but the date 1/1/68
> > was chosen for a reason - it means "divide by 365.25" actually gives the
> > right answer...
>
> Anybody that relies on that in code is bound to get a nasty surprise.
> There are dates for which that doesn't work.  Try it with July 7, 2006.
> Today's date is 14437, a year ago was 14072.  The difference is 365.
> Divide that by 365.25 and you get less than one year.  The argument could
> be made that you could round it after the division, but that will throw
> other dates off.  The bottom line is that this is not a safe way to
> accurately calculate an age - it's *almost* always right, but when that's
> not good enough, it shouldn't be used.
>
> Tim Snyder
> Consulting I/T Specialist
> U2 Lab Services
> Information Management, IBM Software Group
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number

2007-07-11 Thread Timothy Snyder
> I know you said "don't tell me it's the base date", but the date 1/1/68
> was chosen for a reason - it means "divide by 365.25" actually gives the
> right answer...

Anybody that relies on that in code is bound to get a nasty surprise. 
There are dates for which that doesn't work.  Try it with July 7, 2006. 
Today's date is 14437, a year ago was 14072.  The difference is 365. 
Divide that by 365.25 and you get less than one year.  The argument could 
be made that you could round it after the division, but that will throw 
other dates off.  The bottom line is that this is not a safe way to 
accurately calculate an age - it's *almost* always right, but when that's 
not good enough, it shouldn't be used.

Tim Snyder
Consulting I/T Specialist
U2 Lab Services
Information Management, IBM Software Group
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number

2007-07-11 Thread Anthony Youngman
I know you said "don't tell me it's the base date", but the date 1/1/68
was chosen for a reason - it means "divide by 365.25" actually gives the
right answer...

Cheers,
Wol

-Original Message-
From: MAJ Programming [mailto:[EMAIL PROTECTED] 
Sent: 11 July 2007 14:17
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] [UV] Conversion code for week number

Finally, what is the calculation that MV uses for its internal dates?
(Don't
bother telling me the base date, what's the calculation? I don't think
it's
"Thirty days hath September...") I've heard it called Zeller's
Congruence
and I've looked it up but didn't get the direct connection to how our
dates
are incredibly fastly derived/converted.

Thanks in advance
Mark Johnson
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number

2007-07-11 Thread Jerry Banker
Zeller's Congruence finds the day of the week and, at least on UV, isn't
the same as what we use. It is 0 - 6, 0 is Saturday, and UV is 1 - 7, 1
is Monday.

-Original Message-
From: MAJ Programming [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 11, 2007 8:17 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] [UV] Conversion code for week number



Finally, what is the calculation that MV uses for its internal dates?
(Don't
bother telling me the base date, what's the calculation? I don't think
it's
"Thirty days hath September...") I've heard it called Zeller's
Congruence
and I've looked it up but didn't get the direct connection to how our
dates
are incredibly fastly derived/converted.

Thanks in advance
Mark Johnson
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-11 Thread MAJ Programming
Likewise for the business definitions of months and years. I've got clients
that have 13 EVEN 4 week months and one has 12 'months' offset by "no-one
knows why" days and an off year. For example, today, July 11, 2007 is period
06/08, meaning period 06 in year '08'. I ain't making this stuff up.

The 13 EVEN 4 weeks months client has a parent company in Holland. The 06/08
client has their HQ in USA and offices in Belgium and China. Go figure.

It's heavily dependent on control tables as I haven't been able to create a
calculation using a base date and constants to tell me what period September
27, 2004 was in.

BTW this was one of those Y2K things that didn't get resolved, ie the 06/08,
so theres dozens of dict items for sorting in the long-term history files.

One of my client's software REQUIRES that the end of month processing is
performed exactly on the last day of the month, regardless if it's a
saturday, sunday or New Year's Eve. Who were the brain surgeons that wrote
this? I've offered to add some hamburger helper but they wouldn't pay for it
as "it's the way it's always been..."

Finally, what is the calculation that MV uses for its internal dates? (Don't
bother telling me the base date, what's the calculation? I don't think it's
"Thirty days hath September...") I've heard it called Zeller's Congruence
and I've looked it up but didn't get the direct connection to how our dates
are incredibly fastly derived/converted.

Thanks in advance
Mark Johnson


----- Original Message -
From: "Ray Wurlod" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, July 11, 2007 2:00 AM
Subject: Re: [U2] [UV] Conversion code for week number


> There isn't one, and for a very good reason - you have to nail the
business rules, and these won't be the same everywhere.  For example, on
what dat does your week start?  It's Sunday for you (I assume, since you're
in Australia), but it's Monday in the USA.  Some businesses run Thursday
through Wednesday as their week.  The other business rule is the definition
of week number 1 in the year.  Assuming that you want to implement the ISO
8601 standard format Wnn, in which every week has seven days, you must
decide some kind of rule for week number 1 - for example the first week that
has four dates in the calendar year.  Using such a rule January 1st is often
in week #53 of the preceding year.
>
> Of course, if you don't require seven days in every week, and week number
1 starts on January 1st, then you can go with something like
> Int(Oconv(TheDate, "DJ") / 7)
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Conversion code for week number

2007-07-10 Thread Ray Wurlod
There isn't one, and for a very good reason - you have to nail the business 
rules, and these won't be the same everywhere.  For example, on what dat does 
your week start?  It's Sunday for you (I assume, since you're in Australia), 
but it's Monday in the USA.  Some businesses run Thursday through Wednesday as 
their week.  The other business rule is the definition of week number 1 in the 
year.  Assuming that you want to implement the ISO 8601 standard format 
Wnn, in which every week has seven days, you must decide some kind of rule 
for week number 1 - for example the first week that has four dates in the 
calendar year.  Using such a rule January 1st is often in week #53 of the 
preceding year.

Of course, if you don't require seven days in every week, and week number 1 
starts on January 1st, then you can go with something like 
Int(Oconv(TheDate, "DJ") / 7)
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number {unclassified}

2007-07-10 Thread Womack, Adrian
Thanks for that Mike. I'd forgotten about pickwiki.

I found this function which should do the trick:
http://www.pickwiki.com/cgi-bin/wiki.pl?IsoWeekNum

Thanks,
Adrian 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of HENDERSON MIKE,
MR
Sent: Wednesday, 11 July 2007 12:14 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] [UV] Conversion code for week number {unclassified}

Adrian,

This has been discussed before on the list.
IIRC, there is no built-in U2 support (i.e. conversion code) for this,
at least partly because it's one of those nasty 'depends what you mean'
questions.  
For example,
* is the first week in the year week # 0 or 1?
* when does the first week start - the first day in the year, the first
Sunday in the year, the first Monday, ... ?

There is I believe an ISO standard, but that may not be what you want.
There may be something in Pickwiki

Regards

Mike






DISCLAIMER:
Disclaimer.  This e-mail is private and confidential. If you are not the 
intended recipient, please advise us by return e-mail immediately, and delete 
the e-mail and any attachments without using or disclosing the contents in any 
way. The views expressed in this e-mail are those of the author, and do not 
represent those of this company unless this is clearly indicated. You should 
scan this e-mail and any attachments for viruses. This company accepts no 
liability for any direct or indirect damage or loss resulting from the use of 
any attachments to this e-mail.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Conversion code for week number {unclassified}

2007-07-10 Thread HENDERSON MIKE, MR
Adrian,

This has been discussed before on the list.
IIRC, there is no built-in U2 support (i.e. conversion code) for this,
at least partly because it's one of those nasty 'depends what you mean'
questions.  
For example, 
* is the first week in the year week # 0 or 1?
* when does the first week start - the first day in the year, the first
Sunday in the year, the first Monday, ... ?

There is I believe an ISO standard, but that may not be what you want.
There may be something in Pickwiki


Regards


Mike


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Womack, Adrian
Sent: Wednesday, 11 July 2007 3:07 p.m.
To: u2-users@listserver.u2ug.org
Subject: [U2] [UV] Conversion code for week number

Does anyone know of a conversion code that returns the week number of
the year?

The information contained in this Internet Email message is intended
for the addressee only and may contain privileged information, but not
necessarily the official views or opinions of the New Zealand Defence Force.
If you are not the intended recipient you must not use, disclose, copy or 
distribute this message or the information in it.

If you have received this message in error, please Email or telephone
the sender immediately.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/