Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Converting WeekNumber to Weekday

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Converting WeekNumber to Weekday

You can give this a whirl... Use it like

=BOWeek(38, 2007)
to return sept 17, 2007

Function VBAWeekNum(D As Date, FW As Integer) As Integer
'Code by Chip Pearson
VBAWeekNum = CInt(Format(D, "ww", FW))
End Function

Public Function BOWeek(ByVal lngWeek As Long, ByVal lngYear As Long) As Date
Dim lng As Long
Dim lngDaysInWeek1 As Long

For lng = 1 To 7
If VBAWeekNum(DateSerial(lngYear, 1, lng), 1) = 2 Then Exit For
lngDaysInWeek1 = lngDaysInWeek1 + 1
Next lng
BOWeek = DateSerial(lngYear, 1, 1) - (7 - lngDaysInWeek1) + lngWeek * 7
- 6

End Function
--
HTH...

Jim Thomlinson


"JRForm" wrote:

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Converting WeekNumber to Weekday

Or as a worksheet function:-

date in A1
weeknum in b
=DATE(YEAR(A1),1,B1*7-(DAY(DATE(YEAR(A1),1,1)+7-WEEKDAY(DATE(YEAR(A1),1,1),1))))

Mike

"JRForm" wrote:

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Converting WeekNumber to Weekday

On Wed, 19 Sep 2007 09:24:01 -0700, JRForm
wrote:

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks


How are you calculating your week number?

If you are using the Excel WEEKNUM worksheet function, with it's default start
of Sunday for the beginning of the week, then the Monday of that week would be:

=DATE(YEAR(Today()),1,-5)+7*weeknum-WEEKDAY(DATE(YEAR(Today()),1,0))

If you are calculating Week Number using some other method, you'll have to post
that here.
--ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Converting WeekNumber to Weekday

Seems to me you would need to define how you are calculating your week number
first.

http://www.cpearson.com/excel/weeknum.htm

--
Regards,
Tom Ogilvy



"JRForm" wrote:

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Converting WeekNumber to Weekday

Is it possible to use the week number and calculate the date and day of
the
week. For example, Week number 38 would calculate to Monday, September
17.


If the week number is in A1 and the year is in B1, then this formula will
yield September 17, 2007 as you ask for...

=DATE(B1,1,1+7*(A1-1))

Rick

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Converting WeekNumber to Weekday

Thank you Jim this works great!

"Jim Thomlinson" wrote:

You can give this a whirl... Use it like

=BOWeek(38, 2007)
to return sept 17, 2007

Function VBAWeekNum(D As Date, FW As Integer) As Integer
'Code by Chip Pearson
VBAWeekNum = CInt(Format(D, "ww", FW))
End Function

Public Function BOWeek(ByVal lngWeek As Long, ByVal lngYear As Long) As Date
Dim lng As Long
Dim lngDaysInWeek1 As Long

For lng = 1 To 7
If VBAWeekNum(DateSerial(lngYear, 1, lng), 1) = 2 Then Exit For
lngDaysInWeek1 = lngDaysInWeek1 + 1
Next lng
BOWeek = DateSerial(lngYear, 1, 1) - (7 - lngDaysInWeek1) + lngWeek * 7
- 6

End Function
--
HTH...

Jim Thomlinson


"JRForm" wrote:

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Converting WeekNumber to Weekday

Thanks Mike this works good to.

"Mike H" wrote:

Or as a worksheet function:-

date in A1
weeknum in b1
=DATE(YEAR(A1),1,B1*7-(DAY(DATE(YEAR(A1),1,1)+7-WEEKDAY(DATE(YEAR(A1),1,1),1))))

Mike

"JRForm" wrote:

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Converting WeekNumber to Weekday

Thank you Ron.

"Ron Rosenfeld" wrote:

On Wed, 19 Sep 2007 09:24:01 -0700, JRForm
wrote:

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks


How are you calculating your week number?

If you are using the Excel WEEKNUM worksheet function, with it's default start
of Sunday for the beginning of the week, then the Monday of that week would be:

=DATE(YEAR(Today()),1,-5)+7*weeknum-WEEKDAY(DATE(YEAR(Today()),1,0))

If you are calculating Week Number using some other method, you'll have to post
that here.
--ron

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Converting WeekNumber to Weekday

Thank you Tom.

"Tom Ogilvy" wrote:

Seems to me you would need to define how you are calculating your week number
first.

http://www.cpearson.com/excel/weeknum.htm

--
Regards,
Tom Ogilvy



"JRForm" wrote:

I s it possible to use the week number and calculate the date and day of the
week. For example, Week number 38 would calculate to Monday, September 17.

Thanks



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Converting WeekNumber to Weekday

Thank you Rick.

"Rick Rothstein (MVP - VB)" wrote:

Is it possible to use the week number and calculate the date and day of
the
week. For example, Week number 38 would calculate to Monday, September
17.


If the week number is in A1 and the year is in B1, then this formula will
yield September 17, 2007 as you ask for...

=DATE(B1,1,1+7*(A1-1))

Rick


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calendar with weeknumber? Steen Excel Programming 13 March 23rd 10 06:35 PM
=today() = weeknumber Derek M[_2_] Excel Worksheet Functions 3 November 27th 09 12:24 AM
WEEKDAY() function: display TEXT not numeric weekday tom Excel Discussion (Misc queries) 3 November 21st 06 04:32 PM
weeknumber John Britto Excel Discussion (Misc queries) 6 October 7th 05 04:23 PM
Weeknumber in Excel Gunnar From Sweden Excel Discussion (Misc queries) 1 January 5th 05 08:29 AM


All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"