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?

--
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?

>--
>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?

>--
>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?

>--
>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

 Page 1 of 1 [ 6 post ]

Relevant Pages