|
Posted by Erland Sommarskog on 05/31/06 21:54
Uleric (Uleric@gmail.com) writes:
> The date is a minor component to a barcode for a manufacturing process.
> I get the date from the production line as mm-dd-yyyy on the build. I
> have to create a barcode with as few intergers as possible.
Why not
declare @date datetime
select @date = '2006-02-02'
select substring(datename(year, @date), 3, 4) +
substring(convert(char(4), datepart(dayofyear, @date) + 1000), 2, 3)
That's one digit less.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|