I am using an expression in Access to obtain a year value.

  • Thread starter Thread starter Mary
  • Start date Start date
M

Mary

Expr1: Left([NM_Measures_qry.divisionValue],4).
divisionValue can be 2007, 2008, 2009, 2009 1Q, 2009 2Q, 2009 3Q, 2009 4Q,
2010. (Earlier years they did not track quarterly, but going forward they
will.)
I need to add the values if there are more than one record for a year.
This information will be displayed in a bar chart by yearly totals, i.e. the
current year will be a running sum of the year.
I'm sure the solution is simple, but I could use some help with how best to
do this.
 
You can use the Year function instead of the Left function, and it will be
more accurate if there is a 2 digit year:

SELECT Year([DateField]) AS MyYear, Sum(Whatever) AS TotalWhatever
FROM tblMyData
GROUP BY Year([DateField]);
 
Mary

So, won't you end up with 4 X 2009 when you use Left([x],4)? Will that be
OK for your purposes?

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
Back
Top