How to determine last week of a year? 
Author Message
 How to determine last week of a year?

Hello,

I must write a function in VBA that returns the last week of a
particulier year. The input of the function is a year as Integer.
In other words the function should determine if a year is a leap-year.
If it is, it should return 53 else it should return 52.
Can someone give me a example on how to accomplisch this?

Thanks in Advance,

--
Met vriendelijke groet / With kind regard,

Rene van Hoek

http://www.*-*-*.com/ ~rmhoek

--
Met vriendelijke groet / With kind regard,

Rene van Hoek

http://www.*-*-*.com/ ~rmhoek



Mon, 02 Jul 2001 03:00:00 GMT  
 How to determine last week of a year?
Function IsLeapYear(yr As Integer) As Boolean
    If DateDiff("d", "01/01/" & yr, "31/12/" & yr) = 365 Then
        IsLeapYear = True
    Else
        IsLeapYear = False
    End If
End Function
Quote:

>Hello,

>I must write a function in VBA that returns the last week of a
>particulier year. The input of the function is a year as Integer.
>In other words the function should determine if a year is a leap-year.
>If it is, it should return 53 else it should return 52.
>Can someone give me a example on how to accomplisch this?

>Thanks in Advance,

>--
>Met vriendelijke groet / With kind regard,

>Rene van Hoek

>http://www.casema.net/~rmhoek

>--
>Met vriendelijke groet / With kind regard,

>Rene van Hoek

>http://www.casema.net/~rmhoek



Mon, 02 Jul 2001 03:00:00 GMT  
 How to determine last week of a year?
There is a built in function datediff that allows you to take the difference
in 2 dates and return various intervals: datediff(interval, date1, date2).
Just make date1 be 1/1/year and date2 be 12/32/year and the interval be
week. You might want to check the syntax of the function, but that should do
it.


Mon, 02 Jul 2001 03:00:00 GMT  
 How to determine last week of a year?
Try this
Functin GetWeekNum(IntYear as Integer)
    GetWeekNum = Format("12-31-" & IntYear ,"ww")
EndFunction


Quote:
>Hello,

>I must write a function in VBA that returns the last week of a
>particulier year. The input of the function is a year as Integer.
>In other words the function should determine if a year is a leap-year.
>If it is, it should return 53 else it should return 52.
>Can someone give me a example on how to accomplisch this?

>Thanks in Advance,

>--
>Met vriendelijke groet / With kind regard,

>Rene van Hoek

>http://www.casema.net/~rmhoek

>--
>Met vriendelijke groet / With kind regard,

>Rene van Hoek

>http://www.casema.net/~rmhoek



Mon, 02 Jul 2001 03:00:00 GMT  
 How to determine last week of a year?
Thanks all for you respone.

--
Met vriendelijke groet, / With kind regards,

Rene van Hoek


ICQ: 18563404
http://www.casema.net/~rmhoek



Mon, 02 Jul 2001 03:00:00 GMT  
 How to determine last week of a year?
Ren,

A quick way to check for leap years is:

    IsLeapYear = IsDate("2/29/" & YearToCheck)

where "YearToCheck" is a numeric value, the year in question.

This takes advantage of VB's liberal variable typecasting ability to create
a string from "2/29/" & YearToCheck, like "2/29/1999"; and then checks to
see if it's a valid date.

Hope this helps...

--

-cliff knight-


Quote:

>Hello,

>I must write a function in VBA that returns the last week of a
>particulier year. The input of the function is a year as Integer.
>In other words the function should determine if a year is a leap-year.
>If it is, it should return 53 else it should return 52.
>Can someone give me a example on how to accomplisch this?

>Thanks in Advance,

>--
>Met vriendelijke groet / With kind regard,

>Rene van Hoek

>http://www.casema.net/~rmhoek

>--
>Met vriendelijke groet / With kind regard,

>Rene van Hoek

>http://www.casema.net/~rmhoek



Wed, 04 Jul 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. need help determining week of year

2. how to determine "last week"

3. Report: This year by month/ last year by month

4. last year and year to date

5. Compare last 7 days to last calendar week V8.5

6. Week Numbering but on multiple years

7. week of the year

8. Counting weeks, but what about leap year??

9. Week of the year

10. Counting weeks, but what about leap year??

11. Counting weeks, but what about leap year??

12. Counting weeks, but what about leap year??

 

 
Powered by phpBB® Forum Software