Return given time range in production date code フォローする

0
Avatar
Andrew Jenssen

Hi,

 

 In our production date codes, we separate each code in 2 hour intervals with each interval represented by a specific text.  Here's an example of a lot code:

 

20L1637F

20L represents a facility

163 represents production Jullian date (in this case June 12)

7 represents year (in this case 2017)

F represents 2 hour time code (in this case 10:00-12:00)

 

Our time codes could be considered as A=00:00-01:59, B=02:00-03:59, C=04:00-05:59, etc.

 

The first 3 parts of the code are simple, either embedded text or a date function in a string.  My problem starts when attempting to use time ranges in order to lookup my text value.  I'm imagining this is solvable using VB script editing, however I'm a complete novice at this.

 

Does anyone have any recommendations where I can look for additional support or know what kind of script or look ups could be used?  Thank you!

 

-Andrew

1 コメント

1
Avatar
adam cummick
コメントアクション Permalink

I'd try something along the lines of this: Set a variable equal to the current time. Split the result by the ":" characters and take the first chunk(the hour). Put that through some if statements that correspond to your 2 hour increments and sets the value to the appropriate letter. Example:

 

timeNow = time  'get current time

timeNowArray = split(timeNow,":")    'separate 4:32:00 into 3 parts

timeNowHour = CInt(timeNowArray(0))

if( timeNowHour >= 0 And timeNowHour <2) then

value = "A"

else if( timeNowHour >= 0 And timeNowHour <2) then

value = "B"

 

And so on until you cover all the times you need. I haven't run this code, so it probably has some sort of syntax error, but it should be a good start!

サインインしてコメントを残してください。