Re: getting sum of units sold in preceeding weeks

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 05/11/04


Date: Tue, 11 May 2004 15:29:56 +0530


>>it should not add the 1st preceeding week unitssold...<<

  yes, it will not add 1st preceding week's unitssold, All you have to do is
pass right parameter to dateadd function in the query i've posted.

  ex:

  select sum(case when dt_column >= dateadd(dd, -7, {fn current_date()} )and
dt_column <= getdate() then sold_units else 0 end) 'last week',
    sum(case when dt_column >= dateadd(dd, -15, {fn current_date()} ) and
dt_column < dateadd(dd, -8, {fn current_date()} ) then sold_units else 0
end) '2nd last week'
    from
    <table_name>

  If this doesn't satisfy your requirement , pls post table structure and
sample records and expected result set.

  --
  Vishal Parkar
  vgparkar@yahoo.co.in | vgparkar@hotmail.com



Relevant Pages

  • Re: Please help!
    ... the DateAdd function into the query or where in the query to put it (to ... Allen Browne - Microsoft MVP. ... From the 2nd row down to the last is the same duplicate ... I use the DateAdd function? ...
    (microsoft.public.access.forms)
  • Re: Choose the lastest of 2 dates for a calculation involving a third.
    ... it would be best to have some flag in your table to ... The first query would be a top query, where it would be the top 1 based on ... date preceding the "big event" for each primary key related set of records. ... Then simply use the DateDiff function to compare the date returned ...
    (microsoft.public.access.reports)
  • Re: Time Conversion
    ... Use the DateAdd function. ... You can use that formula whereever you need it. ... If you want you could use it in an update query that would populate an ... searches and groupings. ...
    (microsoft.public.access.queries)
  • Re: Date Query
    ... but the DateAdd function gave me the same wrong results as my ... adding two columns - you can hide the second column. ... > When the user makes a selection, pass column two to your query. ...
    (microsoft.public.access.queries)
  • Re: Computing a Date in a Form
    ... Then use a multicolumn combo box that uses this as a query for the ... SELECT fldDays, TimeTermField FROM TableName; ... you could use the DateAdd function to get the new date from today's ... >><MS ACCESS MVP> ...
    (microsoft.public.access.forms)