Weeknumber algorithme 
Author Message
 Weeknumber algorithme

Hi there,
is there anybody who knows the algorithme that gives me the date of let's
say the first day of the week when I give the week number.
So, let's say the week number is 12 and the year is 1998. What is the date
of the first day of the week?
I would greatly appreciate if somebody could give me clue how to tackle
this problem.
Sjef Janssen


Sat, 24 Mar 2001 03:00:00 GMT  
 Weeknumber algorithme

Quote:
>Hi there,
>is there anybody who knows the algorithme that gives me the date of let's
>say the first day of the week when I give the week number.
>So, let's say the week number is 12 and the year is 1998. What is the date
>of the first day of the week?
>I would greatly appreciate if somebody could give me clue how to tackle
>this problem.
>Sjef Janssen

You're in luck, I've just done this my self! The function WeekToDate below
should do the trick. I would test it though if I were you as I've not gotten
around to testing it thoroughly my self.

Function WeekToDate(Week As Integer, Year As Integer) As Date
    Dim fstdow As Byte
    Dim tmpdat As Date

    tmpdat = DateSerial(Year, 1, 1)
    fstdow = WeekDay(tmpdat, 2)

    If fstdow >= 4 Then
        WeekToDate = DateSerial(Year, 1, 9 - fstdow)
    Else
        WeekToDate = DateSerial(Year, 1, 2 - fstdow)
    End If
    WeekToDate = DateAdd("d", 7 * (Week - 2), WeekToDate)
End Function

Regards,
Henrik Grotle
http://home.sol.no/~hgrotle



Fri, 06 Apr 2001 03:00:00 GMT  
 Weeknumber algorithme

Maybe you should take care of one more thing.
How do U specify which is first week of year ?
Maybe one more parameter should solve the problem.

Function WeekToDate(Week As Integer, Year As Integer, FirstWeekIs as Byte) As
Date
    Dim fstdow As Byte
    Dim tmpdat As Date

    tmpdat = DateSerial(Year, 1, 1)
    fstdow = WeekDay(tmpdat, 2)

    If fstdow >= 4 Then
        WeekToDate = DateSerial(Year, 1, 9 - fstdow)
    Else
        WeekToDate = DateSerial(Year, 1, 2 - fstdow)
    End If
    WeekToDate = DateAdd("d", 7 * (Week - 2), WeekToDate, FirstWeekIs)
End Function

Henrik Grotle ha scritto:

Quote:
> >Hi there,
> >is there anybody who knows the algorithme that gives me the date of let's
> >say the first day of the week when I give the week number.
> >So, let's say the week number is 12 and the year is 1998. What is the date
> >of the first day of the week?
> >I would greatly appreciate if somebody could give me clue how to tackle
> >this problem.
> >Sjef Janssen

> You're in luck, I've just done this my self! The function WeekToDate below
> should do the trick. I would test it though if I were you as I've not gotten
> around to testing it thoroughly my self.

> Function WeekToDate(Week As Integer, Year As Integer) As Date
>     Dim fstdow As Byte
>     Dim tmpdat As Date

>     tmpdat = DateSerial(Year, 1, 1)
>     fstdow = WeekDay(tmpdat, 2)

>     If fstdow >= 4 Then
>         WeekToDate = DateSerial(Year, 1, 9 - fstdow)
>     Else
>         WeekToDate = DateSerial(Year, 1, 2 - fstdow)
>     End If
>     WeekToDate = DateAdd("d", 7 * (Week - 2), WeekToDate)
> End Function

> Regards,
> Henrik Grotle
> http://home.sol.no/~hgrotle


  vcard.vcf
< 1K Download


Sun, 08 Apr 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Algorithme?

2. Convert weeknumber and year into a date

3. Weeknumber to select records

4. Dates and Weeknumbers.

5. Weeknumber

6. Converting a weeknumber to a date

7. Date out of weeknumber

8. Europeen Weeknumbers?

9. Date out of weeknumber

10. weeknumber

11. weeknumber

12. Weeknumbers

 

 
Powered by phpBB® Forum Software