The exact ISO 8601-Week-number-Calculation

The exact ISO 8601-Week-number-Calculation

Postby ukoenig » Fri Jan 02, 2009 12:36 pm

Hello,

that was a hard job :oops: :( :( :roll: :shock: :idea: :lol:
Even in internet have been wrong calculations.

Image

Step by step the source is explained :
There is allways a MsgAlert() after each calculation for the result.

Code: Select all  Expand view

SET DATE FORMAT TO "DD/MM/YYYY"
dDate := CTOD( "29/12/2008" )   // Date()
ISO8601Week(dDate)

// -----------------------------------------------
/**
*   ISO-8601 Week Number
*   Processes the week number of a date,
*/
function ISO8601Week(dDate)

// 1) Convert date to Y M D
Y := Year(dDate)
M := Month(dDate)
D := Day(dDate)
WeekNumber := 0
DayOfYear := D
MsgAlert( Y, "1a)  Date-Year" )
MsgAlert( M, "1b)  Date-Month" )
MsgAlert( D, "1c)  Date-Day" )

// 2) Find out if Y is a leap year  (Logic-var) 
// ----------------------------------------------------
isLeapYear := .F.
IF (Y % 4 == 0  .and.  Y % 100 != 0) .or. Y % 400 == 0
   isLeapYear := .T.   
ENDIF
MsgAlert( isLeapYear, "2)  Date is LeapYear" )

// 3) Find out if Year before is a leap year
// --------------------------------------------------
lastYear := Y - 1
lastYearIsLeap := .F.
IF (lastYear % 4 == 0  .and.  lastYear % 100 != 0) .or. lastYear % 400 == 0
   lastYearIsLeap := .T.   
ENDIF
MsgAlert( lastYearIsLeap, "3)  Year before LeapYear" )

// 4) Find the Day of Year Number for Y M D
// ------------------------------------------------------
DayOfYear := 1
aDays := {0,31,59,90,120,151,181,212,243,273,304,334}
DayOfYear := D + aDays[M]
IF isLeapYear = .T. .and. M > 1
   DayOfYear++
ENDIF
MsgAlert( DayOfYear, "4)  Day-Number of Date" )

// 5) Find the weekday for Jan 1 (monday = 1, sunday = 7)
// -------------------------------------------------------------------------
YY := (Y-1) % 100
C := (Y-1) - YY   // get century
G := YY + YY/4
Jan1Weekday := 1 + (((((C / 100) % 4) * 5) + G) % 7)
MsgAlert( INT(Jan1Weekday), "5)  WeekDay of 1. Januar" )

// 6) Find the weekday for Y M D
// ---------------------------------------
H := DayOfYear + (Jan1Weekday - 1)
Weekday := 1 + ((H -1) % 7)
MsgAlert( INT(Weekday), "6)  WeekDay of Date" )

// 7) Find if Y M D falls in YearNumber Y-1, WeekNumber 52 or 53
// ----------------------------------------------------------------------------------
YearNumber = Y
WeekNumber := 0
IF DayOfYear <= (8-Jan1Weekday) .and. Jan1Weekday > 4
   // Date is within the last week of the previous year.
   YearNumber = Y - 1
   IF Jan1Weekday == 5 .or. Jan1Weekday == 6 .and. isLeapYear
      WeekNumber = 53
   else
      WeekNumber = 52
   ENDIF
ENDIF
MsgAlert( YearNumber, "7a)  Falls in Year" )
MsgAlert( WeekNumber, "7b)  Week-Number" )

// 8) Find if Y M D falls in YearNumber Y+1, WeekNumber 1
// --------------------------------------------------------------------------
IF YearNumber == Y
   Number = 365
   IF isLeapYear
      Number = 366
      if (Number - DayOfYear) < (4 - Weekday)
         // Date is within the first week of the next year
         YearNumber = Y + 1
         WeekNumber = 1
      endif
   ENDIF
ENDIF   
MsgAlert( YearNumber, "8a)  Falls in Next-Year" )
MsgAlert( WeekNumber, "8b)  Week-Number in Next Year" )

// 9) Find if Y M D falls in YearNumber Y, WeekNumber 1 through 53
// -------------------------------------------------------------------------------------
IF YearNumber == Y
   // Date is within it's current year.')
   J := DayOfYear + (7 - Weekday) + (Jan1Weekday -1)
   WeekNumber = J / 7
   IF Jan1Weekday > 4
      WeekNumber--
   ENDIF
ENDIF
MsgAlert( INT(WeekNumber), "9)  Week-Number is in Year" )

// RESULT
// ---------
// ---------

ISOWEEK := 0
IF (WeekNumber < 10)
     ISOWEEK := STR(YearNumber) + "-W0" + ALLTRIM(STR(INT(WeekNumber))) + ;
     "-" + ALLTRIM(STR(INT(DayOfYear)))
ENDIF     
IF (WeekNumber > 9)
     ISOWEEK := STR(YearNumber) + "-W" + ALLTRIM(STR(INT(WeekNumber))) + ;
     "-" + ALLTRIM(STR(INT(DayOfYear)))
ENDIF

msgalert(  "ISO- Week-Number : " + ISOWEEK, "Tested Date : " + DTOC(dDate) )

RETURN( WeekNumber )



The calculation problem and useful informations and tests.
---------------------------------------------------------------------

The ISO standard avoids explicitly stating the possible range of week numbers,
but this can easily be deduced from the definition. Possible ISO week numbers are in
the range 01 to 53. A year always has a week 52.
(There is one historic exception: the year in which the Gregorian calendar was introduced
had less than 365 days and less than 52 weeks.)
Proof: Per definition, the first week of a year is W01 and consequently days before
week W01 belong to the previous year and so there is no week with lower numbers.
Considering the highest possible week number, the worst case is a leap year like 1976 that starts
with a Thursday, because this keeps the highest possible number of days of W01 in the
previous year, i.e. 3 days. In this case, the Sunday of W52 of the worst case year is day
number 4+51*7=361 and 361-366=5 days of W53 belong still to this year, which guarantees
that in the worst case year day 4 (Thursday) of W53 is not yet in the next year, so a week
number 53 is possible. For example, the 53 weeks of the worst case year 1976 started
with 1975-12-29 = 1976-W01-1 and ended with 1977-01-02 = 1976-W53-7.

Image
Image

On the other hand, considering the lowest number of the last week of a year, the worst
case is a non-leap year like 1999 that starts with a Friday, which ensures that the first three
days of the year belong to the last week of the previous year. In this case, the Sunday of
week 52 would be day number 3+52*7=367, i.e. only the last 367-365=2 days of the W52
reach into the next year and consequently, even a worst case year like 1999 has a
week W52 including the days 1999-12-27 to 2000-01-02. q.e.d.

Image
Image

Uwe :lol:
Last edited by ukoenig on Sat Jan 03, 2009 1:30 pm, edited 7 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: The exact ISO 8601-week-calculation

Postby Roger Seiler » Fri Jan 02, 2009 8:12 pm

Thanks, Uwe! - Roger
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Re: The exact ISO 8601-week-calculation

Postby ukoenig » Sat Jan 03, 2009 10:06 am

Hello Roger,

I tested the 2 worst cases ( see description ).
The screenshots for the calculations are added.
The Test 1999 is OK.
The Test 1975 ( very extrem ) must show week 1 in 1976 but shows week 53 in 1975.
That is also OK, but not the logic.
Maybe we can ignore it, because this situation doesn't happend again.
I try to find out, if there is still a adjustment needed for this situation.
Please remove the INT(...) inside the calculation, wee need the real values.
For the Alerts, You can keep them ( They are only for testing )
( The changes are allready done in the source. )

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: The exact ISO 8601-Week-number-Calculation

Postby cdmmaui » Tue Dec 08, 2009 2:36 am

Dear Uwe, I tested this code for December 28, 2009 and it is returning Week 53 for 2009, however the week number is 1 for 2010. Any ideas how to resolve?
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: The exact ISO 8601-Week-number-Calculation

Postby nageswaragunupudi » Tue Dec 08, 2009 7:06 am

cdmmaui wrote:Dear Uwe, I tested this code for December 28, 2009 and it is returning Week 53 for 2009, however the week number is 1 for 2010. Any ideas how to resolve?

According to ISO 8601 Week Numbering, this is 2009W53 not 2010W01
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: The exact ISO 8601-Week-number-Calculation

Postby nageswaragunupudi » Tue Dec 08, 2009 7:27 am

Mr Uwe
I think 1975-12-29 should be 1976-W01-01, because 4 days of the week are in 1976. This is not 53rd week of 1975.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: The exact ISO 8601-Week-number-Calculation

Postby nageswaragunupudi » Tue Dec 08, 2009 10:50 am

Mr Uwe

Can you please verify if this function work correctly in all cases?
Code: Select all  Expand view
function ISOWeekDay( dDate )

   local cRet
   local nYear, nDay, nWeek, nWeekDay

   nYear       := Year( dDate )
   nWeek       := Week( dDate )
   nWeekDay    := DoW(  dDate )

   nWeekDay--
   if nWeekDay == 0
      nWeekDay := 7
      nWeek    := Week( dDate - 1 )
   endif

   if Month( dDate ) == 12 .and. nWeek == 1
      nYear++
   elseif Month( ddate ) == 1 .and. nWeek >= 52
      nYear--
   endif

   cRet  := StrZero( nYear, 4 ) + '-W' + StrZero( nWeek, 2 ) + '-' + Str( nWeekDay, 1 )

return cRet
 

This function requires ct.lib for xHarbour and hbct.lib for Harbour to be linked.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: The exact ISO 8601-Week-number-Calculation

Postby StefanHaupt » Tue Dec 08, 2009 11:01 am

Nages,

if you change your function this way, it works fine. The function Week() seems always to return the correct week number.

Code: Select all  Expand view
#INCLUDE "FIVEWIN.CH"

REQUEST HB_LANG_DE        // request the language ID

FUNCTION test()

  LOCAL  dDate // := CTOD( "29.12.2009" )   // Date()

  SET DATE TO GERMAN
  SET CENTURY ON
  HB_LangSelect( "DE")                      // set  the language
  dDate := CTOD( "29.12.1975" )

  ? dDate, Week (dDate), IsoWeekDay(dDate)

  RETURN (nil)


  function ISOWeekDay( dDate, cLangID )

   local cRet
//   local nYear, nDay, nWeek, nWeekDay
   local dCheckDate, nCheckDay

   DEFAULT cLangID := HB_LangSelect ()

   dCheckDate := EoY (dDate)   // always check the last day of the year
   // DoW returns 5 for Thursday, instead of 4.
   // In Germany the first day of the week is monday !
   nCheckDay := IIF (cLangID =="DE", DoW(  dCheckDate )-1, DoW(dCheckDate) )

   nYear       := Year( dCheckDate )
   nWeek       := Week( dCheckDate ) // week() return alway the correct week
   nWeekDay    :=  IIF (cLangID =="DE", DoW(  dDate )-1, DoW(dDate) )

   if nCheckDay < 4   //  4 days of this week or more in the next year ?
     nYear++
   endif

   /*
   if nWeek == 53 .and. Day( dDate ) < 4
      nYear--
   elseif nWeek == 1 .and. Day( dDate ) > 300
      nYear++
   endif
   nWeekDay--
   if nWeekDay == 0
      nWeekDay := 7
   endif
   */


   cRet  := StrZero( nYear, 4 ) + '-W' + StrZero( nWeek, 2 ) + '-' + Str( nWeekDay, 1 )

return cRet
 
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: The exact ISO 8601-Week-number-Calculation

Postby ukoenig » Tue Dec 08, 2009 5:26 pm

It seems, that it works fine now :

Image

Code: Select all  Expand view

REQUEST HB_LANG_DE        // request the language ID

FUNCTION MAIN()
LOCAL oDLG, oGet

SET DATE TO GERMAN
SET CENTURY ON

HB_LangSelect( "DE")                      // set  the language
dDate :=   DATE()
nWeekDay := 1
nWeek := 1
nYear = 1970

DEFINE DIALOG oDlg FROM 5, 5 TO 15, 40 TITLE "Testing Iso-Week"

@ 2, 5 GET oGet VAR dDate SIZE 50, 12

@ 3, 5 BUTTON "&Test" ;
ACTION ( oGet:Refresh(), MsgAlert("Date : " +  DTOC( dDate ) + CRLF + CRLF + ;
        "Iso-Week : " +  IsoWeekDay(dDate) + CRLF + CRLF + ;
        "Year : " +  STR(nYear) + CRLF + ;
        "Week : " +  Str( nWeek ) + CRLF + ;
        "Weekday : " +  Str( nWeekDay ) + CRLF + ;
                "Weekday : " +  CDOW(dDate) + CRLF + ;
        "Leap-Year : " +  IIF( ISLEAPYEAR(YEAR(dDate)) = .T., "  Yes", "  No"), "Informations" ) )

@ 3, 15 BUTTON "&End" ACTION oDlg:End()  

ACTIVATE DIALOG oDlg

RETURN ( NIL )

// ---------------------------

FUNCTION ISOWeekDay( dDate, cLangID )
local cRet
//   local nYear, nDay, nWeek, nWeekDay
local dCheckDate, nCheckDay

DEFAULT cLangID := HB_LangSelect ()

dCheckDate := EoY (dDate)   // always check the last day of the year
// DoW returns 5 for Thursday, instead of 4.
// In Germany the first day of the week is monday !
nCheckDay := IIF (cLangID =="DE", DoW(  dCheckDate )-1, DoW(dCheckDate) )

nYear       := Year( dCheckDate )
nWeek       := Week( dCheckDate ) // week() return alway the correct week
nWeekDay    :=  IIF (cLangID =="DE", DoW(  dDate )-1, DoW(dDate) )

if nCheckDay < 4   //  4 days of this week or more in the next year ?
     nYear++
endif

   /*
   if nWeek == 53 .and. Day( dDate ) < 4
      nYear--
   elseif nWeek == 1 .and. Day( dDate ) > 300
      nYear++
   endif
   nWeekDay--
   if nWeekDay == 0
      nWeekDay := 7
   endif
   */


cRet  := StrZero( nYear, 4 ) + '-W' + StrZero( nWeek, 2 ) + '-' + Str( nWeekDay, 1 )

return cRet
 
// -------------------------------------------------------------

FUNCTION ISLEAPYEAR(ndYear)
local y, lLeap

default ndYear := date()

if valtype(ndYear) == "N"
    y := ndYear
else
    y := year(ndYear)
endif

// Gregorian Calender:

lLeap := ( (y > 0) .and. (y % 4 == 0) .and. ;
             ((y % 100 <> 0) .or. (y % 400 == 0)) )

RETURN(lLeap)
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: The exact ISO 8601-Week-number-Calculation

Postby nageswaragunupudi » Tue Dec 08, 2009 8:05 pm

There is a built in function ISLEAP(<date>) in ct.lib / hbct.lib
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: The exact ISO 8601-Week-number-Calculation

Postby nageswaragunupudi » Thu Dec 10, 2009 5:24 am

Mr. StefanHauft said above
// week() return alway the correct week

Not correct. Week() function is not fully ISO8061 compliant (though the source code cliams to be), because it is based on week from Sun to Sat as 1 to 7.

Also whether HB_LangSelect() is set to 'GE' or 'EN', the result of DoW() is the same.

All the above functions are not correct. They fail for some dates.
Following function gives correct results in all cases. The code is also short and involves minimum computations.
Code: Select all  Expand view
function ISO8061WD( dDate )

   local nWeekDay, dThu, cRet

   nWeekDay       := DoW( dDate ) - 1 // Find weekday
   if nWeekDay == 0                   // Mon to Sun
      nWeekDay    := 7                // as 1 to 7
   endif

   dThu           := dDate - nWeekDay + 4 // Nearest Thursday
   cRet           := Str( Year( dThu ), 4 ) + '-W' + ;
                     StrZero( Int( ( DoY( dThu ) - 1 ) / 7 ) + 1, 2 ) + ;
                     '-'  + Str( nWeekDay, 1 )

return cRet


Logic:
Find weekday using DoW() and adjust to ISO week Mon..Sun ( 1 to 7 )
Find Nearest Thursday
Result is Year of the Nearest Thursday, Week Number of the Nearest Thursday and Adjusted WeekDay of the Given Date calculate already.
Do not use Week function. Instead calculate the week number directly.

The function gave correct results for different dates discussed on the internet.
Here is a limited sample.
Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: The exact ISO 8601-Week-number-Calculation

Postby StefanHaupt » Thu Dec 10, 2009 8:40 am

Nages,

Not correct. Week() function is not fully ISO8061 compliant (though the source code cliams to be), because it is based on week from Sun to Sat as 1 to 7.


Ok, maybe, I did not test it for all possible dates. It worked with 1975 and 2009

Also whether HB_LangSelect() is set to 'GE' or 'EN', the result of DoW() is the same.

Yes, you are right, the result of DoW() does not depend on language settings. So nWeekday := DoW(...) -1 is always correct.

All the above functions are not correct. They fail for some dates.

Can you give me an example which date fails, please.
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: The exact ISO 8601-Week-number-Calculation

Postby nageswaragunupudi » Thu Dec 10, 2009 12:05 pm

Can you give me an example which date fails, please.

When checked in a range of dates from 21.12.1975 to 08.01.1976, only 3 results are correct and 16 results are wrong. A visual inspection of the screenshot below confirms the incorrect results

Third column is result of the function I provided above. Fourth column is the result of the earlier function provided by you.

Image

This is the source code I used
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"

REQUEST HB_LANG_DE

function main()

   local aData, d

   SET DATE GERMAN
   SET CENTURY ON

   HB_LangSelect( 'DE' )

   aData    := {}
   d        := SToD( '19751221' )
   do while d < SToD( '19760109' )

      AAdd( aData, { d, Left( CDoW( d ), 3 ), ISO8061WD( d ), ISO2( d ), .f. } )
      ATail( aData )[ 5 ] := ATail( aData )[ 3 ] == ATail( aData )[ 4 ]
      d++
   enddo


   XBROWSER aData SETUP BrSetUp( oBrw )

return nil

static function BrSetUp( oBrw )

   local aData := oBrw:aArrayData

   oBrw:aCols[ 1 ]:cHeader := 'Date'
   oBrw:aCols[ 2 ]:cHeader := 'Day'
   oBrw:aCols[ 3 ]:cHeader := 'ISO-1'
   oBrw:aCols[ 4 ]:cHeader := 'ISO-2'
   oBrw:aCols[ 5 ]:SetCheck()
   oBrw:aCols[ 5 ]:cHeader := 'Chk'

   oBrw:bClrStd   := { || If( oBrw:aRow[ 5 ], { CLR_BLACK,CLR_WHITE },;
                              { CLR_BLACK, RGB( 255,236,179 ) } ) }

   AEval( oBrw:aCols, { |o| o:nHeadStrAlign := AL_CENTER } )

return nil

function ISO8061WD( dDate )

   local nWeekDay, dThu

   nWeekDay       := DoW( dDate ) - 1 // Find weekday
   if nWeekDay == 0                   // Mon to Sun
      nWeekDay    := 7                // as 1 to 7
   endif

   dThu           := dDate - nWeekDay + 4 // Nearest Thursday

return   Str( Year( dThu ), 4 ) + '-W' + ;
         StrZero( Int( ( DoY( dThu ) - 1 ) / 7 ) + 1, 2 ) + ;
         '-'  + Str( nWeekDay, 1 )


func iso2( dDate, cLangID )

   local cRet
   local nYear, nDay, nWeek, nWeekDay
   local dCheckDate, nCheckDay

   DEFAULT cLangID := HB_LangSelect ()

   dCheckDate := EoY (dDate)   // always check the last day of the year
   // DoW returns 5 for Thursday, instead of 4.
   // In Germany the first day of the week is monday !
   nCheckDay := IIF (cLangID =="DE", DoW(  dCheckDate )-1, DoW(dCheckDate) )

   nYear       := Year( dCheckDate )
   nWeek       := Week( dCheckDate ) // week() return alway the correct week
   nWeekDay    :=  IIF (cLangID =="DE", DoW(  dDate )-1, DoW(dDate) )

   if nCheckDay < 4   //  4 days of this week or more in the next year ?
     nYear++
   endif

   /*
   if nWeek == 53 .and. Day( dDate ) < 4
      nYear--
   elseif nWeek == 1 .and. Day( dDate ) > 300
      nYear++
   endif
   nWeekDay--
   if nWeekDay == 0
      nWeekDay := 7
   endif
   */


   cRet  := StrZero( nYear, 4 ) + '-W' + StrZero( nWeek, 2 ) + '-' + Str( nWeekDay, 1 )

return cRet
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: The exact ISO 8601-Week-number-Calculation

Postby mmercado » Thu Dec 10, 2009 2:39 pm

Hi All:

This standalone function (WeekDate) should work for any date and any country.
Code: Select all  Expand view
#include "FiveWin.ch"

Function Test()

   Local  dDate

   Set Date German
   Set Century On
   Set Epoch To 1980
   dDate := Date()

   While .T.
      If MsgGet( "Test Date",, @dDate )
         MsgInfo( WeekDate( dDate ), "Week Date From " + DtoC( dDate ) )
      Else
         Exit
      EndIf
   EndDo

Return Nil

Function WeekDate( dDate )

   Local nDay, dFirstThu, dThisThu, nWeek

   dFirstThu := StoD( Str( Year( dDate ), 4 ) + "0101" )
   nDay      := If( ( nDay := DoW( dFirstThu ) - 1 ) == 0, 7, nDay )
   dFirstThu := dFirstThu - nDay + 4
   nDay      := If( ( nDay := DoW( dDate ) - 1 ) == 0, 7, nDay )
   dThisThu  := dDate - nDay + 4
   nWeek     := If( Year( dThisThu ) > Year( dFirstThu ), 1, (( dThisThu - dFirstThu ) / 7) + 1 )

Return Str( Year( dThisThu ), 4 ) + '-W' + StrZero( nWeek, 2 ) + '-'  + Str( nDay, 1 )

Best regards.
manuelmercado at prodigy dot net dot mx
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Re: The exact ISO 8601-Week-number-Calculation

Postby nageswaragunupudi » Thu Dec 10, 2009 4:47 pm

Mr Mercado

It appears there is some mistake in this line of your code
Code: Select all  Expand view
  nWeek     := If( Year( dThisThu ) > Year( dFirstThu ), 1, (( dThisThu - dFirstThu ) / 7) + 1 )

Will you please review your code?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 54 guests