2014-10-29 90 views

回答

0

這會給你所有到期日期。

DECLARE @Events TABLE (
    EventID INT IDENTITY(1,1), 
    EventName NVARCHAR(100), 
    StartDate DATE, 
    EndDate DATE 
) 

INSERT INTO @Events VALUES 
    ('name1','11/01/2014','11/02/2014'), 
    ('name2','09/13/2014','09/15/2014'), 
    ('name3','11/02/2014','11/03/2014'), 
    ('name4','09/14/2014','09/17/2014') 

SELECT * FROM @Events WHERE CONVERT(NVARCHAR,GETDATE(),111) < StartDate 

這會給你每月從起始日期:

SELECT SUBSTRING(CONVERT(NVARCHAR,StartDate),6,2) AS StartDateMonth,* FROM @Events 

這會給你當前motnh:

SELECT SUBSTRING(CONVERT(NVARCHAR,GETDATE(),111),6,2) 
相關問題