SQL选择日期为一周或更小的日期

时间:2011-09-15 20:50:40

标签: sql sql-server-2008

我需要在此列中选择一周或更短时间的记录: dbo.mod_employmentAppProfile.dateSubmitted

注意,#arguments.departmentID#是一个coldfusion标记。

这是我的疑问:

    SELECT
        dbo.pro_Profile.profileID, 
        dbo.pro_Profile.firstName, 
        dbo.pro_Profile.lastName, 
        dbo.pro_Profile.isDeleted, 
        dbo.pro_Email.emailAddress, 
        dbo.mod_employmentAppJobTitles.supervisorID, 
        dbo.mod_employmentAppJobs.appID, 
        dbo.mod_employmentAppJobs.isRejected, 
        dbo.mod_employmentAppJobs.isDeleted AS isDeletedJobs, 
        dbo.mod_employmentAppJobs.emailSent, 
        dbo.mod_employmentAppProfile.dateAvailable, 
        dbo.mod_employmentAppProfile.dateSubmitted, 
        dbo.mod_employmentAppProfile.firstName AS appFirstName,
        dbo.mod_employmentAppProfile.lastName AS appLastName, 
        dbo.mod_employmentAppJobTitles.title, 
        dbo.mod_employmentAppProfile.name, 
        dbo.mod_employmentAppProfile.phone, 
        dbo.mod_employmentAppProfile.major, 
        dbo.mod_employmentAppProfile.minor
    FROM dbo.pro_Email 
        INNER JOIN dbo.pro_Profile 
            ON dbo.pro_Email.profileID = dbo.pro_Profile.profileID 
        INNER JOIN dbo.mod_employmentAppJobs 
        INNER JOIN dbo.mod_employmentAppJobTitles 
            ON dbo.mod_employmentAppJobs.jobTitleID = dbo.mod_employmentAppJobTitles.jobTitleID 
        INNER JOIN dbo.mod_employmentAppProfile 
            ON dbo.mod_employmentAppJobs.eAppID = dbo.mod_employmentAppProfile.eAppID 
            ON dbo.pro_Profile.profileID = dbo.mod_employmentAppJobTitles.supervisorID
    WHERE (dbo.mod_employmentAppJobs.emailSent = 0) 
            AND (dbo.mod_employmentAppJobTitles.departmentID = #arguments.departmentID#)
            AND (dbo.mod_employmentAppJobs.isRejected = 0)

我确实尝试过这样的事情:

                 and (dbo.mod_employmentAppProfile.dateSubmitted < DATEADD(day, - 7, GETDATE()))

不返回任何结果。

连连呢?

1 个答案:

答案 0 :(得分:3)

(dbo.mod_employmentAppProfile.dateSubmitted > DATEADD(day, -7, GETDATE()))