Query start time - the end of the time period in how many days this month?
There are multiple data, which found out the statement execution in BBS can only come out when a data, strives for the big help,
DECLARE @ BDATE DATETIME, @ EDATE DATETIME, @ visitnumber varchar (50)
SELECT @ BDATE=StartDtTm, @ EDATE=StopDtTm, @ visitnumber=visitnumber from Orders_IP_Nursing
Select @ visitnumber visitnumber, mon=the convert (varchar (7), dateadd (day, number, @ bdate), 120), [day]=count (*)
From the master.. Spt_values s
Where type='p' and dateadd (day, number, @ bdate) & lt;=@ EDATE
Group by the convert (varchar (7), dateadd (day, number, @ bdate), 120).