Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DateAdd and DateDiff

Status
Not open for further replies.

LazoKazo

Technical User
Jun 25, 2012
1
0
0
CA
Hello All.

I'm trying to pull the quantity sold from OINV for the past year, and divide it into quarters.

I'm relatively new to SQL, so I'm learning how to use the DateAdd and DateDiff to get this done. From my understanding, in order to find the last quarter, I would use the following command.

Select

DateAdd (qq, DateDiff (qq,0,GetDate()) -1,0)

-- How would I incorporate this syntax to break up all of my sales from last year into quarters? Once I have the proper syntax, I plan on bringing this into crystal as a command.

Thanks in advance.
 
In Crystal, you could just insert two groups, one on date->on change of year, and one on date->on change of quarter. Then sum your sales quantities at the group level.

You could alternatively use a formula to return the quarter (again with a higher order year group):

datepart("q",{table.date})

But you don't really need to do this.

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top