Select records from start of month to current date

后端 未结 5 1376
别那么骄傲
别那么骄傲 2021-01-25 08:16

I\'m trying to select records that were added to the database between the start of the current month and the current day - I more or less know how to get records from the curren

5条回答
  •  庸人自扰
    2021-01-25 09:13

    DECLARE @sm DATETIME;
    SET @sm = DATEADD(DAY, 1-DAY(GETDATE()), DATEDIFF(DAY, 0, GETDATE()));
    
    SELECT columns 
        FROM dbo.foo 
        WHERE datetime_column >= @sm;
    

提交回复
热议问题