title: Date arithmetic in Cognos 8
body: <p>What I need is a data item expression which outputs the starting date of the current quarter of last year. Finding the current year is easy, as is subtracting 1 year from that date. But beyond that I get stuck. </p>
  
  <p>I currently have an ugly <code>if</code> expression for each quarter like:</p>
  
  <blockquote>
    <p>if (extract(month,current_date) in (10,12,12))
    then ((extract(year,_add_years (current_date,-1))||'-10-01'))</p>
  </blockquote>
  
  <p>But no matter what I do I can't concatonate the year and date into string I can convert to a date object. The above code gives the error:</p>
  
  <blockquote>
    <p>The operation "add" is invalid for the following combination of data types: "integer" and "character"</p>
  </blockquote>
  
  <p>Trying to cast the integer as a character using <code>cast()</code> I get this error. I also get this error when trying to turn a character array into a date:</p>
  
  <blockquote>
    <p>The operation "condexp" is invalid for the following combination of data types: "character" and "integer"</p>
  </blockquote>
  
  <p>Trying to use SQL Server specific functions (it is a SQL Server database) just gives me an error that those functions are unavailable for local processing, so I can't seem to use SS date arithmatic, and I can't find anything particularly applicable in Cognos' built in date functions.</p>
  
  <p>How can I manipulate a date to add a year to a known day/month combination and use that as a date object?</p>