ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How to display weeknumber with year code (https://www.excelbanter.com/excel-worksheet-functions/54264-how-display-weeknumber-year-code.html)

Lubo

How to display weeknumber with year code
 
I can display weeknumber but I need in front year code in 2 cifers.
Does anyone knows easy solution?

Bob Phillips

How to display weeknumber with year code
 
=TEXT(A1,"yy")&TEXT(weeknum(A1),"00")

--

HTH

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


"Lubo" wrote in message
...
I can display weeknumber but I need in front year code in 2 cifers.
Does anyone knows easy solution?




Ron Rosenfeld

How to display weeknumber with year code
 
On Tue, 8 Nov 2005 03:50:15 -0800, "Lubo"
wrote:

I can display weeknumber but I need in front year code in 2 cifers.
Does anyone knows easy solution?


=TEXT(date,"yy")&TEXT(weeknum(date),"00")

will display a two digit year followed by a two digit weeknumber.

Note that the Excel Weeknum function uses "Excel's definition" of weeknumber
which is not the ISO standard. If you want to use the ISO standard weeknumber,
you'll need a VBA User Defined Function or a complicate worksheet function.

The VBA code for ISO weeknum:

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



--ron


All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com