仅更改sql中日期的月份

时间:2014-06-04 10:59:54

标签: sql

我有readiness_dt列,mm/dd/yyyy中的日期。我想将此日期的月份更新为另一列month中的值。是否有查询只是修改日期的月份 例如。 readiness_dt月       02/14/2013 06
我想要一个应该将readiness_dt更改为06/14/2013的函数

2 个答案:

答案 0 :(得分:0)

试试这个:

SELECT DATEADD(month, 4, '02/14/2013 ')

答案 1 :(得分:0)

这应该有效:

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

请检查这个

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