日期限制-SQL查询

时间:2015-10-13 18:45:25

标签: sql tsql

我在ssis包中有这个查询,我想添加一个约束,如果数据超过4天没有添加它,我该怎么把它添加到这个?

 SELECT PTA,
    Part,
    Duns,
    YearStart AS BlanketYear,
    VIPDoc,
    DID,
    STATUS = CASE 
        WHEN STATUS IS NULL
            THEN 'Eligible'
        ELSE STATUS
        END,
    [PRTCOMACERT STATUS] AS TMSStatus,
    SupplierHTS1 AS HTS,
    PrefCrit,
    Producer,
    NetCost,
    CoCountry AS Country,
    TracedValue,
    Currency,
    MaCountry,
    VEH,
    ENG,
    KitPercent,
    DateCreated,
    DATEDIFF(d, DateCreated, GetDate()) AS AGE
FROM [SourceTempFCA].[dbo].[FCAStatus] g
INNER JOIN [SourceTempFCA].[dbo].[NEW35COMA] t ON g.part = t.PART#PART#
    AND g.duns = t.[PRTCOMASUPPLIER #]
    AND g.yearstart = t.[PRTCOMAEXP DATE  Year]
    AND g.VIPDoc = t.[PRTCOMADOC #]
    --delete from [SourceTempFCA].[dbo].[FCAStatus]

1 个答案:

答案 0 :(得分:0)

这只是一个SELECT声明,所以我假设您要过滤掉这些行?然后就做

WHERE DATEDIFF(d, DateCreated, GetDate()) > 4