473,804 Members | 3,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2081
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.

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

!qryQuartersByC lient:
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********@Fort uneJames.com

Mar 15 '07 #2

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

Similar topics

3
14522
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 submit_date BETWEEN '01/01/2005' AND '03/31/2005' I would like to dynamically generate the Quarter End and Quarter Beginning dates within my where clause based on the date that DTWS
1
4059
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 the quarter fo each region. To help enhance the report I would love to include a comparison to of current sales to previous quarter sales and a comparison of current sales to sales a year ago. I am having a devil of a time creating a query to...
8
11889
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
2863
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 help, Bob
1
6141
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
2472
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 investment firms, and what companies they hold shares of. I set up the query to find all the stocks that a specified company held for the most recent date. But we need to display data for the past dates as well. The way I got the most recent date...
2
7658
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 having difficulties finding the last day of the quarter.
4
11971
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.
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.