Add days in date in yyyymmdd format SQL server -
i have hard-coded date in variable in yyyymmdd format
declare @startdate = 20160101;
now want add 365 days in date.
when 20160101 + 365, gives incorrect output 20160466, should give me answer after adding 365 days think 20160102
please tell me how in sql server in declare variable ? want output in yyyymmdd format
thanks,
aiden
declare @startdate int = '20161117'; select convert(varchar,convert(datetime,convert(char(8),@startdate))+365,112)
Comments
Post a Comment