12,511,665 members (45,476 online)
alternative version

24.3K views
4 bookmarked
Posted

# Get Quarter Starting and Ending Dates for a given Date

, 8 Aug 2010 CPOL
 Rate this:
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)
{
}```

## Share

 India
No Biography provided

## You may also be interested in...

 Pro Pro

 First Prev Next
 Bug Mike_Liu18-Mar-15 2:54 Mike_Liu 18-Mar-15 2:54
 Anyway, I will rewrite function to accept starting month of ... Ravi LVS11-Aug-10 18:36 Ravi LVS 11-Aug-10 18:36
 I removed it intentionally, because it is creating some ambi... Ravi LVS11-Aug-10 18:31 Ravi LVS 11-Aug-10 18:31
 Hello Ravi, where is your QuarterOfDate() method? I think, i... KunalChowdhury9-Aug-10 22:55 KunalChowdhury 9-Aug-10 22:55
 - Kunal No No. Most of the times, every one needs quarter o... Ravi LVS21-Jul-10 7:59 Ravi LVS 21-Jul-10 7:59
 Ravi, I think Luc here is right. The QuarterOfDate() should ... KunalChowdhury21-Jul-10 6:53 KunalChowdhury 21-Jul-10 6:53
 - Luc Pattyn In India 1st qtr = Apr, May, Jun, 2nd Qtr = J... Ravi LVS20-Jul-10 8:50 Ravi LVS 20-Jul-10 8:50
 Reason for my vote of 2 bug Luc Pattyn20-Jul-10 7:48 Luc Pattyn 20-Jul-10 7:48
 QuarterOfDate seems quite wrong, it numbers the quarters as ... Luc Pattyn20-Jul-10 7:47 Luc Pattyn 20-Jul-10 7:47
 Reason for my vote of 5 Very Helpful. KunalChowdhury19-Jul-10 2:35 KunalChowdhury 19-Jul-10 2:35
 Awesome. Nice to see the code. It will be very useful for th... KunalChowdhury19-Jul-10 2:28 KunalChowdhury 19-Jul-10 2:28
 Thank you, I added the function as requested by you. Ravi LVS18-Jul-10 18:27 Ravi LVS 18-Jul-10 18:27
 Super... :) But you can include one method which will return... KunalChowdhury17-Jul-10 4:04 KunalChowdhury 17-Jul-10 4:04
 Last Visit: 31-Dec-99 18:00     Last Update: 30-Sep-16 17:11 Refresh 1