Get Last Quarter Sales

n90

Registered User.
Local time
Today, 12:47
Joined
Dec 6, 2013
Messages
18
So I am writing a query that gets last quarter sales and I'm trying to figure out how to make it so that WHENEVER i run it, it will get the last quarter sales. If it helps the datetime column is called DOCDATE.
 
Basicaly just substract 3 months or 91 days from the system date, then create the quarter from that....
Create a quarter from your table date and stick them both into the where clause.

Or if you want to work with the dates so you can utilize Indexes something along the idea:
Code:
   (Month(Date()) in ( 1, 2, 3) and YourTableDate between Dateserial(year(date())-1,9,1) and dateserial(Year(date()), 1,1)-1)
or (Month(Date()) in ( 4, 5, 6) and YourTableDate between Dateserial(year(date())  ,1,1) and dateserial(Year(date()), 4,1)-1)
or (Month(Date()) in ( 7, 8, 9) and YourTableDate between Dateserial(year(date())  ,4,1) and dateserial(Year(date()), 8,1)-1)
or (Month(Date()) in (10,11,12) and YourTableDate between Dateserial(year(date())  ,7,1) and dateserial(Year(date()),10,1)-1)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom