View Single Post
  #5  
Old March 3rd, 2010, 04:28 PM posted to microsoft.public.access.queries
pat67
external usenet poster
 
Posts: 137
Default changing totals as a date changes

On Mar 3, 11:13*am, KARL DEWEY
wrote:
Try this --
TRANSFORM Sum(tbl_Move_Out_History.[Total Open]) AS [SumOfTotal Open]
SELECT tbl_Move_Out_History.Vendor, tbl_Move_Out_History.[Vendor name]
FROM tbl_Move_Out_History
WHERE [tbl_Move_Out_History].[Extraction Date] Between
DateSerial(Year(Date()), Month(Date()),0) AND DateSerial(Year(Date()),
Month(Date())-2,1)
GROUP BY tbl_Move_Out_History.Vendor, tbl_Move_Out_History.[Vendor name]
PIVOT IIF(Format([tbl_Move_Out_History].[Extraction Date], "yyyymm") =
Format(DateAdd("m", -1, Date()), "yyyymm"), "Current", "Previous");

--
Build a little, test a little.



"pat67" wrote:
On Mar 2, 4:52 pm, KARL DEWEY
wrote:
Post the SQL of your crosstab.
--
Build a little, test a little.


"pat67" wrote:
Not sure if my subject makes sense so I will explain. I need to create
a query that shows open orders for vendors for 2 dates. Previous and
Current. When i run a new query, the old current becomes the new
previous and i add anew surrent. Right now i have 2 dates and i used a
crosstab query and that works fine becuase i can delete one date and
add another. the issue is when i need to find the difference between
the two dates. if i run it now the dates are say 2/1 and 3/1. if i
rerun the data on 4/1, the formulas i used to get the difference form
2/1 and 3/1 won't work. Long story short i need a way to have 2/1 say
previous and 3/1 say current. Longwinded i know. hopefully someone
understands my ramblings
.- Hide quoted text -


- Show quoted text -


Here you go


TRANSFORM Sum(tbl_Move_Out_History.[Total Open]) AS [SumOfTotal Open]
SELECT tbl_Move_Out_History.Vendor, tbl_Move_Out_History.[Vendor name]
FROM tbl_Move_Out_History
GROUP BY tbl_Move_Out_History.Vendor, tbl_Move_Out_History.[Vendor
name]
PIVOT tbl_Move_Out_History.[Extraction Date];


.- Hide quoted text -


- Show quoted text -



I ran that and the result was blank. Vendor and Vendor Name fields
only and no data. Is it because the date format you have is yyymm and
i have mdyyy?