Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Week number and year to date

Status
Not open for further replies.

wabahn

Technical User
Oct 23, 2008
20
US
Hopefully this is an easy question. I am in excel and have the manufacture year and week number for a product. I would like to convert this to a Friday date for the week of manufacture since we only ship on Fridays. Does anyone have a simple solution?
 

Do you have any examples of what you want to do?

Have fun.

---- Andy
 
i guess a starting point would be to find out the date of the first friday of the year...

to do that i guess you could work out which day the first of jan was in that year and add the differing days

then to find the date for the week and year you want you simply do a dateadd for the number of weeks - 1 (for the first week!!)

get first day of year
Code:
Dim datval As Date
dim myDayVal as int 
dim startDate as date

datval = "01/01/2010"
myDayVal = datval.DayOfWeek

'check for saturday
if myDayVal = 6 then myDayVal = -1
mydayval = ((mydayval - 5) * -1)

'first fiday 
startdate = dateadd(d,mydayval,startdate)

'get friday date
msgbox (dateadd(w,10,startdate)

I haven't checked the code, but thats probably one of the routes to take!!

daveJam

it works on my machine, so technically i win!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top