SQL Server Group By Month

前端 未结 7 1284
攒了一身酷
攒了一身酷 2020-12-13 01:53

I have a table which has this schema

ItemID    UserID    Year    IsPaid    PaymentDate  Amount
1         1         2009    0         2009-11-01  300
2                


        
7条回答
  •  佛祖请我去吃肉
    2020-12-13 02:18

    DECLARE @start [datetime] = 2010/4/1;
    

    Should be...

    DECLARE @start [datetime] = '2010-04-01';
    

    The one you have is dividing 2010 by 4, then by 1, then converting to a date. Which is the 57.5th day from 1900-01-01.

    Try SELECT @start after your initialisation to check if this is correct.

提交回复
热议问题