Difference between revisions of "Presage/Internal:Great American Date Codes"

From ISoft Wiki
Jump to navigationJump to search
(Added info about Simplot date codes and cleaned up the code snipets a bit)
 
(One intermediate revision by one other user not shown)
Line 10: Line 10:
*The 'J' represents the time between midnight and 2 a.m. (controlled by the second of the nested case statement).
*The 'J' represents the time between midnight and 2 a.m. (controlled by the second of the nested case statement).
*Finally, the '1' indicates the line number within the plant where the product was produced.
*Finally, the '1' indicates the line number within the plant where the product was produced.
{{Code|text=(SELECT <br>
<source lang='text'>
CASE <br>
(SELECT CASE WHEN {?Date Code Format} = "Wahoo" THEN
WHEN {?Date Code Format} = "Wahoo" THEN <br>
CONCAT('N',  
 
CONCAT('N', <br>
CASE  
CASE <br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'A'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'A'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'B'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'B'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'C'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'C'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'D'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'D'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'E'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'E'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'F'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'F'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'G'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'G'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'H'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'H'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'I'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'I'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'J'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'J'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'K'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'K'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'L'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'L'<br>
END,
END, <br>
 
date_format({?Check Timestamp},'%d'),<br>
date_format({?Check Timestamp},'%d'),
RIGHT(DATE_FORMAT({?Check Timestamp},'%y'),1),<br>
RIGHT(DATE_FORMAT({?Check Timestamp},'%y'),1),
CASE <br>
 
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '05:00:00' AND '07:59:59' THEN 'A'<br>
CASE  
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '08:00:00' AND '09:59:59' THEN 'B'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '05:00:00' AND '07:59:59' THEN 'A'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '10:00:00' AND '11:59:59' THEN 'C'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '08:00:00' AND '09:59:59' THEN 'B'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '12:00:00' AND '13:59:59' THEN 'D'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '10:00:00' AND '11:59:59' THEN 'C'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '14:00:00' AND '15:59:59' THEN 'E'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '12:00:00' AND '13:59:59' THEN 'D'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '16:00:00' AND '17:59:59' THEN 'F'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '14:00:00' AND '15:59:59' THEN 'E'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '18:00:00' AND '19:59:59' THEN 'G'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '16:00:00' AND '17:59:59' THEN 'F'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '20:00:00' AND '21:59:59' THEN 'H'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '18:00:00' AND '19:59:59' THEN 'G'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '22:00:00' AND '23:59:59' THEN 'I'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '20:00:00' AND '21:59:59' THEN 'H'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '00:00:00' AND '01:59:59' THEN 'J'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '22:00:00' AND '23:59:59' THEN 'I'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '02:00:00' AND '03:59:59' THEN 'K'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '00:00:00' AND '01:59:59' THEN 'J'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '04:00:00' AND '04:59:59' THEN 'L'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '02:00:00' AND '03:59:59' THEN 'K'
END,<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '04:00:00' AND '04:59:59' THEN 'L'
{?Line})<br>
END,
<br>
{?Line})
END)}}
END)
The code above references a choice {?Date Code Format} techs select against the {?Check Timestamp} in an analysis. The date format is compared against a code on the product's packaging the tech enters into the Ideal Date Code option. This assures the product packaging is labeled properly. An option name must always be preceeded by '{?' and followed by '}' to be recognized as an analysis option. [This link https://www.w3schools.com/SQL/func_date_format.asp] offers a list of date formats for MySQL.
</source>
 
The code above references a choice {?Date Code Format} techs select against the {?Check Timestamp} in an analysis. The date format is compared against a code on the product's packaging. This assures the product packaging is labeled properly. An option name must always be preceded by '{?' and followed by '}' to be recognized as an analysis option. [This link https://www.w3schools.com/SQL/func_date_format.asp] offers a list of date formats for MySQL.


<h2>Best Before/Meilleur Avant YYYY MO DD + Wahoo</h2>
<h2>Best Before/Meilleur Avant YYYY MO DD + Wahoo</h2>
Line 55: Line 57:
For a date of '''2017-06-05 00:15:01''' (produced on '''Line 1''' in the '''Nampa''' plant), the Date Code would display as ''''Best Before/Meilleur Avant 2018 JN05 NF057J1''''.
For a date of '''2017-06-05 00:15:01''' (produced on '''Line 1''' in the '''Nampa''' plant), the Date Code would display as ''''Best Before/Meilleur Avant 2018 JN05 NF057J1''''.


{{Code|text=(select case WHEN {?Retail Date Code Format} = "Best Before/Meilleur Avant YYYY MO DD + Wahoo" THEN <br>
<source lang='text'>
CONCAT('Best Before/Meilleur Avant ', DATE_FORMAT(DATE_ADD({?Check Timestamp}, INTERVAL 12 month), '%Y '), LEFT(date_format(date_add({?Check Timestamp}, interval 12 month),<br>
(SELECT CASE WHEN {?Retail Date Code Format} = "Best Before/Meilleur Avant YYYY MO DD + Wahoo" THEN  
CASE <br>
CONCAT('Best Before/Meilleur Avant ', DATE_FORMAT(DATE_ADD({?Check Timestamp}, INTERVAL 12 month), '%Y '), LEFT(date_format(date_add({?Check Timestamp}, interval 12 month),
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'JA'<br>
 
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'FE'<br>
CASE  
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'MR'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'JA'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'AL'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'FE'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'MA'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'MR'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'JN'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'AL'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'JL'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'MA'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'AU'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'JN'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'SE'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'JL'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'OC'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'AU'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'NO'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'SE'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'DE'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'OC'
END),2), <br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'NO'
date_format(date_add({?Check Timestamp}, interval 12 month),'%d'),  ' N', <br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'DE'
CASE <br>
END),2),  
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'A'<br>
date_format(date_add({?Check Timestamp}, interval 12 month),'%d'),  ' N',  
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'B'<br>
 
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'C'<br>
CASE  
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'D'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'A'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'E'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'B'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'F'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'C'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'G'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'D'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'H'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'E'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'I'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'F'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'J'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'G'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'K'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'H'
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'L'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'I'
END,  <br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'J'
date_format({?Check Timestamp},'%d'),<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'K'
RIGHT(DATE_FORMAT({?Check Timestamp},'%y'),1),<br>
WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'L'
CASE <br>
END,   
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '05:00:00' AND '07:59:59' THEN 'A'<br>
date_format({?Check Timestamp},'%d'),
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '08:00:00' AND '09:59:59' THEN 'B'<br>
RIGHT(DATE_FORMAT({?Check Timestamp},'%y'),1),
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '10:00:00' AND '11:59:59' THEN 'C'<br>
 
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '12:00:00' AND '13:59:59' THEN 'D'<br>
CASE  
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '14:00:00' AND '15:59:59' THEN 'E'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '05:00:00' AND '07:59:59' THEN 'A'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '16:00:00' AND '17:59:59' THEN 'F'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '08:00:00' AND '09:59:59' THEN 'B'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '18:00:00' AND '19:59:59' THEN 'G'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '10:00:00' AND '11:59:59' THEN 'C'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '20:00:00' AND '21:59:59' THEN 'H'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '12:00:00' AND '13:59:59' THEN 'D'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '22:00:00' AND '23:59:59' THEN 'I'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '14:00:00' AND '15:59:59' THEN 'E'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '00:00:00' AND '01:59:59' THEN 'J'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '16:00:00' AND '17:59:59' THEN 'F'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '02:00:00' AND '03:59:59' THEN 'K'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '18:00:00' AND '19:59:59' THEN 'G'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '04:00:00' AND '04:59:59' THEN 'L'<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '20:00:00' AND '21:59:59' THEN 'H'
END,<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '22:00:00' AND '23:59:59' THEN 'I'
{?Line})<br>
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '00:00:00' AND '01:59:59' THEN 'J'
END)}}
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '02:00:00' AND '03:59:59' THEN 'K'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '04:00:00' AND '04:59:59' THEN 'L'
END,
{?Line})
END)
</source>
 
<h2>Simplot</h2>
As far as I know, the Simplot format is only used in the Nampa plant. It has the format:
 
PPP MM DD YY L T
 
*PPP = plant of production
*MMM = Month of production (Alpha)
*DD = Day of Production
*YY = Year of Production
*L = Line of Production
*T = Time Interval of Production
 
Here is an example of a Simplot date code format when it is filled out with information:
 
968 JUN 16 17 4 3
 
<source lang='text'>
(SELECT CASE WHEN {?Date Code Format} = {?Date Code Format} THEN
CONCAT('968 ', DATE_FORMAT({?Check Timestamp},'%b %d %y'), ' ', {?Line}, ' ', CASE
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '05:00:00' AND '07:59:59' THEN '1'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '08:00:00' AND '09:59:59' THEN '2'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '10:00:00' AND '11:59:59' THEN '3'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '12:00:00' AND '13:59:59' THEN '4'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '14:00:00' AND '15:59:59' THEN '5'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '16:00:00' AND '17:59:59' THEN '6'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '18:00:00' AND '19:59:59' THEN '7'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '20:00:00' AND '21:59:59' THEN '8'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '22:00:00' AND '23:59:59' THEN '9'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '00:00:00' AND '01:59:59' THEN '10'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '02:00:00' AND '03:59:59' THEN '11'
WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '04:00:00' AND '04:59:59' THEN '12'
END)
END)
</source>

Latest revision as of 11:04, 16 June 2017

Great American [Appetizers] Snacks has unique date codes for their packaging.

The Wahoo Date Code

The Wahoo code is used in both the Nampa and Monroe plants for a number of analyses. For a date of 2017-06-05 00:15:01 (produced on Line 1 in the Nampa plant), the Wahoo Code would display as 'NF057J1'

  • The 'N' stands for Nampa. The Monroe plant's initial character is 'M'.
  • The 'F' stands for the month of June (controlled by the first of the nested case statement).
  • The '05' is the day of the month formatted as a two-digit day using the format '%d'.
  • The '7' is the last number of the four-digit year using the RIGHT command to find the first digit on the right of the number, using the format '%y'.
  • The 'J' represents the time between midnight and 2 a.m. (controlled by the second of the nested case statement).
  • Finally, the '1' indicates the line number within the plant where the product was produced.
(SELECT CASE WHEN {?Date Code Format} = "Wahoo" THEN
	CONCAT('N', 

	CASE 
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'A'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'B'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'C'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'D'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'E'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'F'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'G'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'H'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'I'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'J'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'K'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'L'
	END,

	date_format({?Check Timestamp},'%d'),
	RIGHT(DATE_FORMAT({?Check Timestamp},'%y'),1),

	CASE 
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '05:00:00' AND '07:59:59' THEN 'A'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '08:00:00' AND '09:59:59' THEN 'B'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '10:00:00' AND '11:59:59' THEN 'C'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '12:00:00' AND '13:59:59' THEN 'D'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '14:00:00' AND '15:59:59' THEN 'E'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '16:00:00' AND '17:59:59' THEN 'F'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '18:00:00' AND '19:59:59' THEN 'G'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '20:00:00' AND '21:59:59' THEN 'H'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '22:00:00' AND '23:59:59' THEN 'I'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '00:00:00' AND '01:59:59' THEN 'J'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '02:00:00' AND '03:59:59' THEN 'K'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '04:00:00' AND '04:59:59' THEN 'L'
	END,
{?Line})
END)

The code above references a choice {?Date Code Format} techs select against the {?Check Timestamp} in an analysis. The date format is compared against a code on the product's packaging. This assures the product packaging is labeled properly. An option name must always be preceded by '{?' and followed by '}' to be recognized as an analysis option. [This link https://www.w3schools.com/SQL/func_date_format.asp] offers a list of date formats for MySQL.

Best Before/Meilleur Avant YYYY MO DD + Wahoo

The Nampa plant requested a new date code for a product distributed in Canada. They requested month abbreviations that are not standard to MySQL. Therefore we used a case statement instead of using the date formats. That code looks like the code below. It concatenates 'Best Before/Meilleur Avant ' with the four-digit year, the two-character month (in the first case statment), the two-digit day, and the Wahoo Date Code (above).

For a date of 2017-06-05 00:15:01 (produced on Line 1 in the Nampa plant), the Date Code would display as 'Best Before/Meilleur Avant 2018 JN05 NF057J1'.

(SELECT CASE WHEN {?Retail Date Code Format} = "Best Before/Meilleur Avant YYYY MO DD + Wahoo" THEN 
	CONCAT('Best Before/Meilleur Avant ', DATE_FORMAT(DATE_ADD({?Check Timestamp}, INTERVAL 12 month), '%Y '), LEFT(date_format(date_add({?Check Timestamp}, interval 12 month),

	CASE 
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'JA'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'FE'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'MR'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'AL'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'MA'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'JN'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'JL'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'AU'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'SE'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'OC'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'NO'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'DE'
	END),2), 
	date_format(date_add({?Check Timestamp}, interval 12 month),'%d'),  ' N', 

	CASE 
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 1 THEN 'A'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 2 THEN 'B'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 3 THEN 'C'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 4 THEN 'D'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 5 THEN 'E'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 6 THEN 'F'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 7 THEN 'G'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 8 THEN 'H'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 9 THEN 'I'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 10 THEN 'J'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 11 THEN 'K'
	WHEN DATE_FORMAT({?Check Timestamp},'%c') = 12 THEN 'L'
	END,  
	date_format({?Check Timestamp},'%d'),
	RIGHT(DATE_FORMAT({?Check Timestamp},'%y'),1),

	CASE 
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '05:00:00' AND '07:59:59' THEN 'A'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '08:00:00' AND '09:59:59' THEN 'B'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '10:00:00' AND '11:59:59' THEN 'C'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '12:00:00' AND '13:59:59' THEN 'D'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '14:00:00' AND '15:59:59' THEN 'E'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '16:00:00' AND '17:59:59' THEN 'F'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '18:00:00' AND '19:59:59' THEN 'G'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '20:00:00' AND '21:59:59' THEN 'H'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '22:00:00' AND '23:59:59' THEN 'I'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '00:00:00' AND '01:59:59' THEN 'J'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '02:00:00' AND '03:59:59' THEN 'K'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '04:00:00' AND '04:59:59' THEN 'L'
	END,
{?Line})
END)

Simplot

As far as I know, the Simplot format is only used in the Nampa plant. It has the format:

PPP MM DD YY L T

  • PPP = plant of production
  • MMM = Month of production (Alpha)
  • DD = Day of Production
  • YY = Year of Production
  • L = Line of Production
  • T = Time Interval of Production

Here is an example of a Simplot date code format when it is filled out with information:

968 JUN 16 17 4 3

(SELECT CASE WHEN {?Date Code Format} = {?Date Code Format} THEN 
	CONCAT('968 ', DATE_FORMAT({?Check Timestamp},'%b %d %y'), ' ', {?Line}, ' ', CASE 
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '05:00:00' AND '07:59:59' THEN '1'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '08:00:00' AND '09:59:59' THEN '2'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '10:00:00' AND '11:59:59' THEN '3'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '12:00:00' AND '13:59:59' THEN '4'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '14:00:00' AND '15:59:59' THEN '5'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '16:00:00' AND '17:59:59' THEN '6'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '18:00:00' AND '19:59:59' THEN '7'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '20:00:00' AND '21:59:59' THEN '8'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '22:00:00' AND '23:59:59' THEN '9'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '00:00:00' AND '01:59:59' THEN '10'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '02:00:00' AND '03:59:59' THEN '11'
	WHEN DATE_FORMAT({?Check Timestamp},'%T') BETWEEN '04:00:00' AND '04:59:59' THEN '12'
	END)
END)