Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
srlincoln
Starting Member
1 Post |
Posted - 2007-03-20 : 17:41:16
|
Need to know how to sum the data of one field, many records, for a particular year.I've got a Yearly Totals field that I want to show all the sum of the current years data from another Totals field. Same Table and everything...I also have a field that called Last years total that I would like to show the sum of all of last years data...And when the year changes, I'd like those fields to dynamically change. So I don't want to put in a date range thing of 1/1/2007 to 12/31/2007 type thing. I want to do something like Current year minus 1 (for last years data) and Current Year for this years data.Help! And Thanks.-Sam |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-06 : 07:03:51
|
This is for SQL Server which you can easily simulate to ACCESSFor last yearSelect.....Where datecol>=dateadd(year,datediff(year,0,Getdate())-1,0)and datecol<dateadd(year,datediff(year,0,Getdate()),0)Current yearWhere datecol>=dateadd(year,datediff(year,0,Getdate()),0)and datecol<dateadd(year,datediff(year,0,Getdate())+1,0)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|