sql server 2005 - Convert datetime to numeric -
i trying take date in varchar column in table, add 1 day it, , set value of datetime variable. part of process runs daily , need make sure day resets 1 @ end of month. or @ end of year doesn't increase 151231 151232. problem having converting @date numeric in form yymmdd. example virn_chk = '151231', @date written below 'jan 1 2016 12:00am'. need convert 160101 can save in column in table of type numeric(6,0).
declare @date datetime set @date = convert(varchar,dateadd(d, 1,(select top(1) virn_chk stage_inst))) update cdcdatei set ot_date = @date
this work rebuilding string format
select right(year('2015-11-01'),2) + right('00' + cast(month('2015-11-01') varchar(2)),2) + right('00' + cast(day('2015-11-01') varchar(2)),2)
Comments
Post a Comment