Click here to Skip to main content
11,931,718 members (61,016 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked

Get Quarter Starting and Ending Dates for a given Date

, 8 Aug 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Get Quarter Starting and Ending Dates for a given Date
When you want the Quarter Starting and Ending dates for a given date, here are simple functions to calculate.

//whichQtr =  0 - present quarter
//           -1 - previous quarter
//            1 - next quarter
public static DateTime QuarterEnddate(DateTime curDate, int whichQtr)
   int tQtr = (curDate.Month - 1) / 3 + 1 + whichQtr;
   return new DateTime(curDate.Year, (tQtr * 3) + 1, 1).AddDays(-1);
public static DateTime QuarterStartDate(DateTime curDate, int whichQtr)
   return QuarterEnddate(curDate, whichQtr).AddDays(1).AddMonths(-3);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ravi LVS
India India
No Biography provided

You may also be interested in...

Comments and Discussions

BugBug Pin
Mike_Liu18-Mar-15 3:54
memberMike_Liu18-Mar-15 3:54 
GeneralAnyway, I will rewrite function to accept starting month of ... Pin
Ravi LVS11-Aug-10 19:36
memberRavi LVS11-Aug-10 19:36 
GeneralI removed it intentionally, because it is creating some ambi... Pin
Ravi LVS11-Aug-10 19:31
memberRavi LVS11-Aug-10 19:31 
GeneralHello Ravi, where is your QuarterOfDate() method? I think, i... Pin
KunalChowdhury9-Aug-10 23:55
mvpKunalChowdhury9-Aug-10 23:55 
General- Kunal No No. Most of the times, every one needs quarter o... Pin
Ravi LVS21-Jul-10 8:59
memberRavi LVS21-Jul-10 8:59 
GeneralRavi, I think Luc here is right. The QuarterOfDate() should ... Pin
KunalChowdhury21-Jul-10 7:53
mvpKunalChowdhury21-Jul-10 7:53 
General- Luc Pattyn In India 1st qtr = Apr, May, Jun, 2nd Qtr = J... Pin
Ravi LVS20-Jul-10 9:50
memberRavi LVS20-Jul-10 9:50 
GeneralReason for my vote of 2 bug Pin
Luc Pattyn20-Jul-10 8:48
mvpLuc Pattyn20-Jul-10 8:48 
GeneralQuarterOfDate seems quite wrong, it numbers the quarters as ... Pin
Luc Pattyn20-Jul-10 8:47
mvpLuc Pattyn20-Jul-10 8:47 
GeneralReason for my vote of 5 Very Helpful. Pin
KunalChowdhury19-Jul-10 3:35
mvpKunalChowdhury19-Jul-10 3:35 
GeneralAwesome. Nice to see the code. It will be very useful for th... Pin
KunalChowdhury19-Jul-10 3:28
mvpKunalChowdhury19-Jul-10 3:28 
GeneralThank you, I added the function as requested by you. Pin
Ravi LVS18-Jul-10 19:27
memberRavi LVS18-Jul-10 19:27 
GeneralSuper... :) But you can include one method which will return... Pin
KunalChowdhury17-Jul-10 5:04
mvpKunalChowdhury17-Jul-10 5:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151126.1 | Last Updated 8 Aug 2010
Article Copyright 2010 by Ravi LVS
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid