Ujjwal Vaish Ujjwal Vaish - 3 months ago 13
SQL Question

change only the month of a date in sql

i have a column

which is a date in
.I want to update the month of this date to the value present in another column
. Is there a query to just modify the month for a date.

E.g. readiness_dt month
02/14/2013 06

I want a function which should change the readiness_dt to 06/14/2013

hsd hsd

This should work:

SELECT DATEADD (month, 'your column name from 
      another table','xx/xx/xxxx') 
from 'your other table'


    create table date_test(
    interval int)

    insert into date_test values (1)

    insert into date_test values (2)

    insert into date_test values (3)

    select * from date_test

    select GETDATE() as Cur_date, DATEADD(month,interval,GETDATE()) as Interval_Added     

    from date_test

Please check this as well

Is it possible to use values from another table as the interval in a DATEADD function?