0

Aim: Update Column C 'New Date' based on finding a value in Column B 'valuefield'. Column C 'New Date' will be a date from Column A 'Current Date'

I have used the below in the past but I am now asked for a third argument. I have search and tried "YYYY-MM-DD" at the end but can't quite make the leap to the answer.

Software:I am using SQL in Server Management(2012)

UPDATE TBLTABLE
SET  NewDate= (CurrentDate + DATEADD(DAY,730)) 
WHERE VALUEFIELD = 'XYZ'

Notes: Updating with a known value I know but I don't 'know' the value of each 'Current Date' field and this also ensures I don't have to run distinct date.

Looked at: Update Field based on another table's Field values

Update a column based on a field from another table

SQL UPDATE SET one column to be equal to a value in a related table referenced by a different column?

Community
  • 1
  • 1
indofraiser
  • 1,014
  • 3
  • 18
  • 50

1 Answers1

1

It realy depends what is in CurrentDate. I guess its a datetime.

   UPDATE TBLTABLE
    SET  NewDate=  DATEADD(DAY,730,CurrentDate )
    WHERE VALUEFIELD = 'XYZ'
Mathias F
  • 15,906
  • 22
  • 89
  • 159