Your technology certification is waiting. Enroll in Cloud Class ®
Declare @dt datetime = '20131114 22:28'
'7884' + replace(convert(varchar, @dt ,3),'/','') as "7884 ddmmyy"
, '7884' + replace(convert(varchar, @dt ,1),'/','') as "7884 mmddyy"
Open in new window
(CAST ('7884' as varchar) + cast(convert(varchar, trans_date,12)as varchar))
Declare @dt datetime = '11/14/13 22:28'
SELECT '7884' +
RIGHT('0' + CAST(DATEPART(d, @dt) as varchar(2)),2) +
RIGHT('0' + CAST(DATEPART(m, @dt) as varchar(2)),2) +
RIGHT(CAST(YEAR(@dt) as char(4)),2)
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.