Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
msbutton27
 
Posts: n/a
Default How can I convert a date into a week number...

Hello,

I am trying to determine if it is possible to convert a 6 digit number into
a week - for example:
050525 = yymmdd = 2005, May 25th
and I want my field to determine what the week number of the year is...

This week is week 21, therefore based on my entry of the date format above I
want the week column autofilled...

Is this possible?

Thanks - Have a Good One!!

  #2   Report Post  
msbutton27
 
Posts: n/a
Default

I also forgot to mention that the nubmer in my first column (the date) is
actually part of a bigger number, therefore I want to know how I can parse
the data...ie:

050523-23432
I only need
050523

....Mike

"msbutton27" wrote:

Hello,

I am trying to determine if it is possible to convert a 6 digit number into
a week - for example:
050525 = yymmdd = 2005, May 25th
and I want my field to determine what the week number of the year is...

This week is week 21, therefore based on my entry of the date format above I
want the week column autofilled...

Is this possible?

Thanks - Have a Good One!!

  #3   Report Post  
N Harkawat
 
Posts: n/a
Default

=WEEKNUM(DATE((LEFT(A1,2)+2000),(MID(A1,3,2)),(MID (A1,5,2))))

you will need to install Analysis took pak add-in to use the weeknum
function
and also assumed that 05 in the first part of the year is always 2005 and
not 1995

Also 2005, May 25th gives me week 22 and NOT week 21


"msbutton27" wrote in message
...
I also forgot to mention that the nubmer in my first column (the date) is
actually part of a bigger number, therefore I want to know how I can parse
the data...ie:

050523-23432
I only need
050523

...Mike

"msbutton27" wrote:

Hello,

I am trying to determine if it is possible to convert a 6 digit number
into
a week - for example:
050525 = yymmdd = 2005, May 25th
and I want my field to determine what the week number of the year is...

This week is week 21, therefore based on my entry of the date format
above I
want the week column autofilled...

Is this possible?

Thanks - Have a Good One!!



  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

This looks like an ISO weeknum you are wanting, so I would do it in 2 steps

In B1, add this formula

=DATE(2000+MID(A1,5,2,MID(A1,1,2)),MID(A1,3,2))

and then in C1, add

=1+INT((--B1-DATE(YEAR(B1+4-WEEKDAY(B1+6)),1,5)+WEEKDAY(DATE(YEAR(B1+4-WEEKD
AY(B1+6)),1,3)))/7)

BTW I am assuming that those dates are US format, if not in B1 use

=DATE(2000+MID(A1,5,2),MID(A1,3,2),MID(A1,1,2))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"msbutton27" wrote in message
...
I also forgot to mention that the nubmer in my first column (the date) is
actually part of a bigger number, therefore I want to know how I can parse
the data...ie:

050523-23432
I only need
050523

...Mike

"msbutton27" wrote:

Hello,

I am trying to determine if it is possible to convert a 6 digit number

into
a week - for example:
050525 = yymmdd = 2005, May 25th
and I want my field to determine what the week number of the year is...

This week is week 21, therefore based on my entry of the date format

above I
want the week column autofilled...

Is this possible?

Thanks - Have a Good One!!



  #5   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

Here is a formula from Daniel Maher, with the date in A1

=1+INT(MIN(MOD(A1-DATE(YEAR(A1)+{-1;0;1},1,5)+WEEKDAY(DATE(YEAR(A1)+{-1;0;1},1,3)),734))/7)

Daniel also wrote an ISO week function

Public Function IsoWeekNum(d1 As Date) As Integer
' Daniel Maher
Dim d2 As Long
d2 = DateSerial(Year(d1 - Weekday(d1 - 1) + 4), 1, 3)
IsoWeekNum = Int((d1 - d2 + Weekday(d2) + 5) / 7)
End Function


Press Alt + F11, click insert module and paste in the code, press alt + Q to
close the VBE and then use as

=IsoWeekNum(A1)


Regards,

Peo Sjoblom


"msbutton27" wrote:

I also forgot to mention that the nubmer in my first column (the date) is
actually part of a bigger number, therefore I want to know how I can parse
the data...ie:

050523-23432
I only need
050523

...Mike

"msbutton27" wrote:

Hello,

I am trying to determine if it is possible to convert a 6 digit number into
a week - for example:
050525 = yymmdd = 2005, May 25th
and I want my field to determine what the week number of the year is...

This week is week 21, therefore based on my entry of the date format above I
want the week column autofilled...

Is this possible?

Thanks - Have a Good One!!



  #6   Report Post  
msbutton27
 
Posts: n/a
Default

Bob - do i need to install any addon's for your suggestion - I am unable to
enter your first B1 Date command, complains that there are two many comands
for this function...

....Mike


"Bob Phillips" wrote:

This looks like an ISO weeknum you are wanting, so I would do it in 2 steps

In B1, add this formula

=DATE(2000+MID(A1,5,2,MID(A1,1,2)),MID(A1,3,2))

and then in C1, add

=1+INT((--B1-DATE(YEAR(B1+4-WEEKDAY(B1+6)),1,5)+WEEKDAY(DATE(YEAR(B1+4-WEEKD
AY(B1+6)),1,3)))/7)

BTW I am assuming that those dates are US format, if not in B1 use

=DATE(2000+MID(A1,5,2),MID(A1,3,2),MID(A1,1,2))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"msbutton27" wrote in message
...
I also forgot to mention that the nubmer in my first column (the date) is
actually part of a bigger number, therefore I want to know how I can parse
the data...ie:

050523-23432
I only need
050523

...Mike

"msbutton27" wrote:

Hello,

I am trying to determine if it is possible to convert a 6 digit number

into
a week - for example:
050525 = yymmdd = 2005, May 25th
and I want my field to determine what the week number of the year is...

This week is week 21, therefore based on my entry of the date format

above I
want the week column autofilled...

Is this possible?

Thanks - Have a Good One!!




  #7   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Wed, 25 May 2005 12:47:02 -0700, "msbutton27"
wrote:

I also forgot to mention that the nubmer in my first column (the date) is
actually part of a bigger number, therefore I want to know how I can parse
the data...ie:

050523-23432
I only need
050523


Well, to parse out the date, assuming the above structu

=DATE(LEFT(A1,2)+1900+100*(--LEFT(A1,2)<29),MID(A1,3,2),MID(A1,5,2))

To determine the weeknumber depends on your definition.

There are the various Excel definitions -- see the WEEKNUM worksheet function.

However, there is also an ISO standard which is not supported by the Excel
WEEKNUM worksheet function but can be computed using this UDF:

===========================
Function ISOWeeknum(dt As Date) As Integer
ISOWeeknum = DatePart("ww", dt, vbMonday, vbFirstFourDays)
If ISOWeeknum 52 Then
If DatePart("ww", dt + 7, vbMonday, vbFirstFourDays) = 2 Then
ISOWeeknum = 1
End If
End If
End Function
============================

To enter this UDF, <alt+F11 opens the VB Editor.
Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the above code into the window that opens.

To use this function:

=ISOWeeknum(your_date)

Putting it all together, with your string in A1, the ISO weeknumber can be
computed using the formula:

=isoweeknum(DATE(LEFT(A1,2)+1900+100*(
--LEFT(A1,2)<29),MID(A1,3,2),MID(A1,5,2)))

Be sure to format the cell as General (or Number)


--ron
  #8   Report Post  
Bob Phillips
 
Posts: n/a
Default

Mike,

Sorry I hade to change before posting as I have UK dates, and a ) got out of
place. Try

=DATE(2000+MID(A1,5,2),MID(A1,1,2),MID(A1,3,2))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"msbutton27" wrote in message
...
Bob - do i need to install any addon's for your suggestion - I am unable

to
enter your first B1 Date command, complains that there are two many

comands
for this function...

...Mike


"Bob Phillips" wrote:

This looks like an ISO weeknum you are wanting, so I would do it in 2

steps

In B1, add this formula

=DATE(2000+MID(A1,5,2,MID(A1,1,2)),MID(A1,3,2))

and then in C1, add


=1+INT((--B1-DATE(YEAR(B1+4-WEEKDAY(B1+6)),1,5)+WEEKDAY(DATE(YEAR(B1+4-WEEKD
AY(B1+6)),1,3)))/7)

BTW I am assuming that those dates are US format, if not in B1 use

=DATE(2000+MID(A1,5,2),MID(A1,3,2),MID(A1,1,2))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"msbutton27" wrote in message
...
I also forgot to mention that the nubmer in my first column (the date)

is
actually part of a bigger number, therefore I want to know how I can

parse
the data...ie:

050523-23432
I only need
050523

...Mike

"msbutton27" wrote:

Hello,

I am trying to determine if it is possible to convert a 6 digit

number
into
a week - for example:
050525 = yymmdd = 2005, May 25th
and I want my field to determine what the week number of the year

is...

This week is week 21, therefore based on my entry of the date format

above I
want the week column autofilled...

Is this possible?

Thanks - Have a Good One!!






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
user defined function Brian Rogge Excel Worksheet Functions 5 May 23rd 05 06:21 PM
Where is DateDiff function in Excel 2002 ? Nigel Welch Excel Worksheet Functions 4 March 4th 05 03:18 PM
How do I convert a number formated as a date to text in Excel? BrotherNov Excel Discussion (Misc queries) 5 March 2nd 05 03:51 PM
How do I convert a Julian date into a regular date? Jessica Excel Discussion (Misc queries) 4 December 2nd 04 02:54 AM
Dynamic Column VlookUps Based on Week Number TLK40us Excel Worksheet Functions 3 November 14th 04 03:33 PM


All times are GMT +1. The time now is 07:05 AM.

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"