/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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
URL: http://www.developerdotstar.com/community/node/319