Return to Snippet

Revision: 34027
at October 16, 2010 05:39 by ramirocalero


Initial Code
DECLARE @Date VARCHAR(8)
SET @Date = CAST(YEAR(GETDATE()) AS VARCHAR(4))
SET @Date = @Date + REPLICATE('0', 2 - DATALENGTH(CAST(MONTH(GETDATE()) as VARCHAR))) + CAST(MONTH(GETDATE()) as VARCHAR) 
SET @Date = @Date + REPLICATE('0', 2 - DATALENGTH(CAST(DAY(GETDATE()) as VARCHAR))) + CAST(DAY(GETDATE()) as VARCHAR) 
SELECT @Date

Initial URL
http://www.developerdotstar.com/community/node/319

Initial Description

                                

Initial Title
Agreagar 0 a la izquierda de un numero o fecha. Padleft

Initial Tags
sql, date

Initial Language
SQL