'SQL string (help converting date number to year)

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



Solution 1:[1]

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

Solution 2:[2]

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

If the fields are from two different tables you need to join the tables based on their relation, but in this case, it is not clear what is the relation between tables?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Md. Tarikul Islam Soikot
Solution 2