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

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -