|
|
C#
DateTime datetime = DateTime.Now;
int currQuarter = (datetime.Month - 1) / 3 + 1;
DateTime dtFirstDay = new DateTime(datetime.Year, 3 * currQuarter - 2, 1);
DateTime dtLastDay = new DateTime(datetime.Year, 3 * currQuarter + 1, 1).AddDays(-1);
Response.Write("First Day of Quarter - " + dtFirstDay.ToShortDateString() + " : " +
"Last Day of Quarter - " + dtLastDay.ToShortDateString());
VB.NET
Dim datetime As DateTime = DateTime.Now
Dim currQuarter As Integer = (datetime.Month - 1) / 3 + 1
Dim dtFirstDay As New DateTime(datetime.Year, 3 * currQuarter - 2, 1)
Dim dtLastDay As New DateTime(datetime.Year, 3 * currQuarter + 1, 1).AddDays(-1)
Response.Write("First Day of Quarter - " & dtFirstDay.ToShortDateString() & " : " _
& "Last Day of Quarter - " & dtLastDay.ToShortDateString())
'Like' us on our FaceBook page if you find this blog useful. Thanks!
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |





comments
3 Responses to "Find the First and Last Day of the Current Quarter"very useful for my application. How can i find last day of previous month using DateTime class?
Quarter 4 was giving me fits. I changed to...
Dim currQuarter As Integer = CType((Date.Today.Month - 1) / 3 + 1, Integer)
Dim dtFirstDay As Date = New DateTime(Date.Today.Year, 3 * currQuarter - 2, 1)
Dim dtLastDay As Date = New DateTime(dtFirstDay.Year, dtFirstDay.Month + 2, 1).AddMonths(1).AddDays(-1)
Post a Comment