Home > Enterprise >  SQL string (help converting date number to year)
SQL string (help converting date number to year)

Time:02-22

I have a date field then a number field ( # of Years) I want to add then covert back to a date.

partlot.MfgDt   Part.number01  

What would be the simplest way?

enter image description here

CodePudding user response:

If I got you right, this is the query in SQL Server

SELECT cast(DATEADD(year, YearsCol, DateCol) as datetime) as newDate FROM TableName

YearsCol is your number field and DateCol is your date field

CodePudding user response:

If I am not wrong, you are trying to add year in Date column.

In SQL Server you can use this:-

SELECT DATEADD(year, IntervalYear, DateColumn) FROM TableName
  • Related