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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I convert Year and Week to date? 2

Status
Not open for further replies.

Tomadams

Programmer
Jun 26, 2001
141
US
I am given the date built for a product as 0323 where 03 represents the year and 23 represents the week. How do I change that to a mm/dd/yyyy format? I know I'll have t take the first day of the week, but that will meet my needs.

thanks
 
Tom,
Code:
DVal = 0323
If CInt(left(DVal, 2) < 30 then
  Cent = 2000
Else
  Cent = 1900
End If
Yr = Cent + CInt(left(DVal, 2)
Wk = CInt(Right(DVal, 2)
MyDate = DateSerial(yr, 1, 1) + (Wk - 1) * 7
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Skip it worked great for me! You get a Star. I did have to correct a few things to get it to work but I got the genral idea. Here is what I did for anyone elese trying the same thing.

Dim dval as string
Dim yr
Dim wk
Dim cent
Dim mydate As Date
dval = "0508"
If CInt(Left(dval, 2)) < 30 Then
cent = 2000
Else
cent = 1900
End If
yr = cent + CInt(Left(dval, 2))
wk = CInt(Right(dval, 2))
mydate = DateSerial(yr, 1, 1) + (wk - 1) * 7
MsgBox mydate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top