ViciousXUSMC Posted June 19, 2015 Posted June 19, 2015 (edited) I am looking to put Manufacture dates on a barcode for our computers.HP has the date inside the serial# on the computer.An example 2UA1410VL7Where the 4th number is the single digit year, and the 5th and 6th numbers are a 2 digit week.So this computer was made in 2011 due to the 1 and week 41, aka First Week of OctoberHow can I parse this out so that I can plug in a serial# and have it spit out a date like 10/07/2011I thought it over and did my best, and this appears to be working as desired but I cant help but feel I did this "brute force" and there is a better way so hope the better programmers can chime in on a better way to convert this, or let me know my way was not bad.expandcollapse popup#Include <Array.au3> ;Example Serial 2UA1410VL7 ;XXXYWWXXXXX MsgBox(0, "", MDate("2UA1410VL7")) Func MDate($vSerial) ;Pull 3rd Digit from Current Year for a good chance to get the current proper 10 year set to match with serial ;and get 4th digit from serial that represents the current year $Year = StringMid(@Year, 1, 3) & StringMid($vSerial, 4, 1) ;Check Year Result ;MsgBox(0, "", $Year) ;Pull Raw # of Weeks from Serial # as a 2 Digit Number $Week = StringMid($vSerial, 5, 2) ;Check Week Result ;MsgBox(0, "", $Week) ;Divide Rawe Weeks by 4 to get Months.Weeks $RawMonth = $Week /4 ;Split Months and Weeks into an Array $aMonth = StringSplit($RawMonth, ".") ;See Array Results ;_ArrayDisplay($aMonth) $Month = $aMonth[1] ;Check "Day" Value ;MsgBox(0, "", $aMonth[2]) ;Set Days if Array has only 2 reults Then no deicmal was found in divison so assume first day of month, else assume 7 days for each "week" If $aMonth[0] = 2 Then Switch $aMonth[2] Case 25 $Day = "07" Case 5 $Day = "14" Case 75 $Day = "21" EndSwitch Else $Day = "01" EndIf ;Check Day Result ;MsgBox(0, "", $Day) $Manufacture = $Month & "/" & $Day & "/" & $Year Return $Manufacture EndFunc Edited June 19, 2015 by ViciousXUSMC
BrewManNH Posted June 19, 2015 Posted June 19, 2015 Look at StringMid. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Moderators JLogan3o13 Posted June 19, 2015 Moderators Posted June 19, 2015 Just out of curiosity, how does the 1 tell you 2011 and not 2010 or 2001? Was there a different number scheme before 2010? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
BrewManNH Posted June 19, 2015 Posted June 19, 2015 They probably start at 0 for 2000 or 2010 depending upon the model, and go up to 9 for 2009 or 2019. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
ViciousXUSMC Posted June 19, 2015 Author Posted June 19, 2015 (edited) I think they just assume you wont be messing with a computer more than 10 years old. So they only give you a single digit for the year.By serial number alone maybe there is no way to tell (without looking it up online) but when looking at a computer you can tell if its old/new Edited June 19, 2015 by ViciousXUSMC
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now