title: Must declare scalar variable datetime
body: <p>Please help me. Why is this code not working? Says <code>@FromDate</code> must declare scalar variable</p>
  
  <pre><code>Alter Procedure rpt_1
  as
      declare @FromDate Datetime 
      declare @ToDate Datetime
      declare @LocId int
  Begin
      select 
          cl.CashLocationName, 
          convert(date,fn.DocumentDate) DocumentDate, 
          u.UserName,
          sum(TotalPayment) TotalVanzare, sum(CashAmount) TotalCash, 
          sum(CardAmount) TotalCard, sum(TicketPaymentAmount) TotalTichete, 
          sum(VATAmount)as TVA,
          count(FiscalNoteId) as NrBon, 
          round(sum(TotalPayment) / count(FiscalNoteId), 2) as ValoareMedieCos, 
          max(InternalTime) as MomentInchidere
      from 
          FiscalNote fn (nolock)
      Join 
          CashLocation cl (nolock) on cl.CashLocationId = fn.CashLocationId
      Join 
          ERPUser u (nolock) on u.UserId = fn.UserId  
      join 
          Site s (nolock) on s.SiteId = fn.SiteId
      where 
          DocumentDate &gt;= @FromDate and DocumentDate &lt;= @ToDate 
          and s.SiteId = @LocId  
          and fn.DocumentStateId = 36
      group by 
          cl.CashLocationName, fn.DocumentDate, OpenCashLocationMovementId, 
          u.UserName
      order by 
          DocumentDate,  CashLocationName, UserName
  end
  </code></pre>