sql server 2008 - sql format function -


i trying execute following query, error function format not exist.

create table [prods](     [id] [int] not null,     [shippeddate] [datetime] not null,     [shipid] (format([shippeddate], 'yymm','en-us') +right('00000' + convert([varchar],[id]).(6))) ) 

what doing wrong?

the format function available in sql server 2012+.

formatting dates in 2008 , earlier bit cumbersome. can do

right(cast(year([shippeddate]) nvarchar(4)), 2)      + right('0' + cast(month([shippeddate]) nvarchar(2)), 2)  

to string consisting of 2 digit year plus 2 digit month.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -