Hi ramco1917,
Please refer below sample.
HTML
<asp:TextBox ID="txtDate" runat="server" Text="01/10/2022" />
<asp:Button Text="Select" runat="server" OnClick="Select" />
<hr />
<asp:GridView ID="gvQuarters" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Quarter" HeaderText="Quarters" />
<asp:BoundField DataField="Start" HeaderText="Start Date" DataFormatString="{0:dd-MM-yyyy}" />
<asp:BoundField DataField="End" HeaderText="End Date" DataFormatString="{0:dd-MM-yyyy}" />
</Columns>
</asp:GridView>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Select(object sender, EventArgs e)
{
DateTime dt = Convert.ToDateTime(txtDate.Text);
DateTime startDay = new DateTime(dt.Year, dt.Month, 1);
DateTime endDay = startDay.AddMonths(3).AddDays(-1);
DataTable dtQuarters = new DataTable();
dtQuarters.Columns.Add("Quarter");
dtQuarters.Columns.Add("Start", typeof(DateTime));
dtQuarters.Columns.Add("End", typeof(DateTime));
dtQuarters.Rows.Add("Quarter 1", startDay, endDay);
endDay = endDay.AddDays(1);
dtQuarters.Rows.Add("Quarter 2", endDay, endDay.AddMonths(3).AddDays(-1));
endDay = endDay.AddMonths(3).AddDays(-1).AddDays(1);
dtQuarters.Rows.Add("Quarter 3", endDay, endDay.AddMonths(3).AddDays(-1));
endDay = endDay.AddMonths(3).AddDays(-1).AddDays(1);
dtQuarters.Rows.Add("Quarter 4", endDay, endDay.AddMonths(3).AddDays(-1));
gvQuarters.DataSource = dtQuarters;
gvQuarters.DataBind();
}
VB.Net
Protected Sub Select(ByVal sender As Object, ByVal e As EventArgs)
Dim dt As DateTime = Convert.ToDateTime(txtDate.Text)
Dim startDay As DateTime = New DateTime(dt.Year, dt.Month, 1)
Dim endDay As DateTime = startDay.AddMonths(3).AddDays(-1)
Dim dtQuarters As DataTable = New DataTable()
dtQuarters.Columns.Add("Quarter")
dtQuarters.Columns.Add("Start", GetType(DateTime))
dtQuarters.Columns.Add("End", GetType(DateTime))
dtQuarters.Rows.Add("Quarter 1", startDay, endDay)
endDay = endDay.AddDays(1)
dtQuarters.Rows.Add("Quarter 2", endDay, endDay.AddMonths(3).AddDays(-1))
endDay = endDay.AddMonths(3).AddDays(-1).AddDays(1)
dtQuarters.Rows.Add("Quarter 3", endDay, endDay.AddMonths(3).AddDays(-1))
endDay = endDay.AddMonths(3).AddDays(-1).AddDays(1)
dtQuarters.Rows.Add("Quarter 4", endDay, endDay.AddMonths(3).AddDays(-1))
gvQuarters.DataSource = dtQuarters
gvQuarters.DataBind()
End Sub
Screenshot