468,758 Members | 2,087 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,758 developers. It's quick & easy.

Convert a Number to Years and Weeks only

Hi,
Is there a code that converts a whole number to Years and Weeks only?

Thanks,
Bull

Oct 2 '07 #1
2 1646
On Oct 1, 11:20 pm, Bull <MrsFore...@gmail.comwrote:
Hi,
Is there a code that converts a whole number to Years and Weeks only?

Thanks,
Bull
Your question makes as much sense as converting a whole number to
apples. However, if you want to add weeks and years to a date, you
could use the following.

newDate=DateAdd("w",years*52+weeks,oldDate)

Oct 2 '07 #2
Try this if you just want to have a function that gives you the week
number for a particular date, and the second function returns you just
the year...

Function VBAWeekNum(D As Date, FW As Integer) As Integer
VBAWeekNum = CInt(Format(D, "ww", FW))
End Function

Function VBAYear(D As Date) As Integer
VBAYear = CInt(Format(D, "YYYY"))
End Function

Quick and easy :-)

Cheers

The Frog

Oct 4 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Richard Hollenbeck | last post: by
9 posts views Thread by mprocopio | last post: by
7 posts views Thread by Shuffs | last post: by
12 posts views Thread by dixie | last post: by
3 posts views Thread by Soren Jorgensen | last post: by
14 posts views Thread by Tommy Jakobsen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.