Hello,
I am trying to get a leading zero for the DatePart function for the month. Here is the code:
SELECT CONVERT(CHAR(9),
'C' +
CONVERT(CHAR(4),DATEPART(YYYY,GETDATE())) +
CONVERT(CHAR(2),DATEPART(MM,GETDATE())) +
'15' ) AS ContractorHeader
Output: C20031 15
I would like to get a zero between the 3 and 1 but I am not sure how this would be done.
Thank you again,
TomR100
I am trying to get a leading zero for the DatePart function for the month. Here is the code:
SELECT CONVERT(CHAR(9),
'C' +
CONVERT(CHAR(4),DATEPART(YYYY,GETDATE())) +
CONVERT(CHAR(2),DATEPART(MM,GETDATE())) +
'15' ) AS ContractorHeader
Output: C20031 15
I would like to get a zero between the 3 and 1 but I am not sure how this would be done.
Thank you again,
TomR100