11,931,718 members (61,016 online)
alternative version

20.8K 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...

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