473,382 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

showing every quarter between 2 dates

I relay need some help I am looking to find every quarter between 2
dates here is an example of what i am trying to do

data table

client sbegin send
499 1-1-2000 6-1-2001
499 12-12-05 12-21-05
499 10-5-06 12-15-06
499 12-1-06 12-10-06
499 6-5-07 6-6-07
so the results would be

client Quarter Year
499 1 00
499 2 00
499 3 00
499 4 00
499 1 01
499 2 01
499 4 05
499 4 06
499 2 07

How would i do this

Mar 15 '07 #1
1 2065
On Mar 14, 8:42 pm, mnol...@jeffco.us wrote:
I relay need some help I am looking to find every quarter between 2
dates here is an example of what i am trying to do

data table

client sbegin send
499 1-1-2000 6-1-2001
499 12-12-05 12-21-05
499 10-5-06 12-15-06
499 12-1-06 12-10-06
499 6-5-07 6-6-07

so the results would be

client Quarter Year
499 1 00
499 2 00
499 3 00
499 4 00
499 1 01
499 2 01
499 4 05
499 4 06
499 2 07

How would i do this
Auxiliary table method:

tblData
DID AutoNumber
Client Long
sbegin Date/Time m-d-yy
send Date/Time m-d-yy

DID Client sbegin send
1 499 1-1-00 6-1-01
2 499 12-12-05 12-21-05
3 499 10-5-06 12-15-06
4 499 12-1-06 12-10-06
5 499 6-5-07 6-6-07

tblIntegers
ID AutoNumber
theInt Long

ID theInt
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
....

tblIntegers should have enough values to cover the largest number of
quarters expected.

qryQuartersByClient:
SELECT DISTINCT Year(DateAdd("q", tblIntegers.theInt - 1,
tblData.sbegin)) As theYear, DatePart("q", DateAdd("q",
tblIntegers.theInt - 1, tblData.sbegin)) As theQuarter, Client FROM
tblData, tblIntegers WHERE theInt <= 9 AND DateAdd("q",
tblIntegers.theInt - 1, tblData.sbegin) BETWEEN tblData.sbegin AND
tblData.send;

!qryQuartersByClient:
theYear theQuarter Client
2000 1 499
2000 2 499
2000 3 499
2000 4 499
2001 1 499
2001 2 499
2005 4 499
2006 4 499
2007 2 499

Note: This query is not very efficient. I put 'theInt <=9 AND' in for
efficiency in case the auxiliary table is huge. It should be O.K.
without that part. Post back if you need something better and I'll
see what I can do.

James A. Fortune
CD********@FortuneJames.com

Mar 15 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt | last post by:
Hello, I have a query that I would like to schedule in DTS. The criteria of this query checks for records in the table that are within the current quarter. Here is what I have. WHERE...
1
by: Terencetrent | last post by:
I have created a query that examines qarterly sales for 5 regions in the country. The query contains data for the past 6 quarters for each region and calculates the perecentage of total sales for...
8
by: Dominique Vandensteen | last post by:
I have a datetime and want to format it to "quarter year" so 20 december 2003 should give: "4-2003" is this possible? I don't find a format character for quarter :-( Dominique
3
by: RD | last post by:
Say Company's financial year starts October First and say we are now March 17th. How do you determine which quarter of the Financial year - not the actual year - March 17th is in. Thanks for any...
1
by: JIM.H. | last post by:
Hello, In C#, I need to find StartDate and EndDate of a quarter for a given date. How can I do that? Thanks,
2
by: markcarroll | last post by:
I have a rather complicating query (the SQL is about a page long) so I hope I can solve this without needing to get into specifics. Basically, the database I am working on has information about...
2
benchpolo
by: benchpolo | last post by:
First Day of the QUARTER select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0) Question: How do I get the last DAY of the QUARTER? For example: 1st Quarter is 01/01/2008 to 03/31/2008. I am...
4
by: gimme_this_gimme_that | last post by:
Is there a way to get the last day of the previous business quarter from DB2? For 10/21/2008 the day would be 9/30/2008. Thanks.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.