Yearly sales report with Pivot

I have a SQL query to get a sales report with this year and last year.

In this Query i declared the following:
DECLARE @cols VARCHAR (30)
DECLARE @cols2 VARCHAR (30)

DECLARE @query NVARCHAR (MAX)
set @cols = convert(varchar,year(getdate()))  + ',' + convert(varchar,year(getdate()) -1)
set @cols2 = '[' + convert(varchar,year(getdate()) ) + '],[' + convert(varchar,year(getdate()) -1) + ']'

This query works fine. But when I use it within FastReport how to use it to get this year and last year dynamic in the report.

I have it working, but now I use:
  m_AantalDitJaar.Memo.Text:='[DBXQ_Factuuregels."2018"]';
  m_AantalVorigJaar.Memo.Text:='[DBXQ_Factuuregels."2017"]';

And I can't get it working like this:
  m_AantalDitJaar.Memo.Text:='[DBXQ_Factuuregels.<YearOf(DATE)]';
  m_AantalVorigJaar.Memo.Text:='[DBXQ_Factuuregels.YearOf(DATE)-1]';

Does any one have a clue?

Comments

  • edited March 2018
    I did found it:
    m_AantalDitJaar.Memo.Text:='[DBXQ_Factuuregels."' + IntToSTR(YEAROF(<Date>)) + '"]';
    

Leave a Comment