471,049 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,049 software developers and data experts.

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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.