Hi All,
For a quite convoluted reason I need to bulid a string which contains the month as two digits. I came up with the following sql statement
But seems to me there must be a much much sleaker way to achive the same thing, any help would be appreciated.Code:declare @month int set @month = (select cast(datepart(m,getdate()) as integer)) declare @lmonth varchar(2) set @lmonth = CASE WHEN @month <10 THEN '0' + cast(@month as varchar) ELSE cast(@month as varchar) END select @lmonth




Reply With Quote