473,326 Members | 2,136 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,326 software developers and data experts.

Q: quarter's start and end dates

Hello,

In C#, I need to find StartDate and EndDate of a quarter for a given date.
How can I do that?
Thanks,

Nov 23 '05 #1
1 6122
Don't think there's a built-in method, but isn't this pretty trivial.
Forgive me for being a n00b, but don't you just need to do:

//assumes August 1st is your business start of year
DateTime startOfNewYear = new DateTime(DateTime.Now.Year, 8,1);
DateTime startOfFirstQuarter = startOfNewYear;
DateTime startOfSecondQuarter = startOfNewYear.AddMonths(3);
DateTime startOfThirdQuarter = startOfNewYear.AddMonths(6);
DateTime startOfForthQuarter = startOfNewYear.AddMonths(9);

DateTime endOfFirstQuarter = startOfSecondQuarter.AddDays(-1);
DateTime endOfSecondQuarter = startOfThirdQuarter.AddDays(-1);
DateTime endOfThirdQuarter = startOfForthQuarter.AddDays(-1);
DateTime endOfForthQuarter = startOfNewYear.AddYears(1).AddDays(-1);

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
Hello,

In C#, I need to find StartDate and EndDate of a quarter for a given date.
How can I do that?
Thanks,

Nov 23 '05 #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: mnoland | last post by:
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...
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.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.