ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Check if DateTime is Weekend or public Holiday using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="Tevin">Tevin</a>,</p> <p>Take reference to below code according to your requirement write insert code after checking condition.</p> <p>Define your public Holidays Date in the Array.</p> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Generate(object sender, EventArgs e) { var publicHolidays = new[] { new DateTime(2019, 1, 1), new DateTime(2019, 1, 26), new DateTime(2019, 3, 4), new DateTime(2019, 4, 6), new DateTime(2019, 4, 19), new DateTime(2019, 5, 1) }; DateTime start = new DateTime(2019, 01, 01); foreach (var item in publicHolidays) { if (item != start &amp;&amp; item.DayOfWeek != DayOfWeek.Saturday &amp;&amp; item.DayOfWeek != DayOfWeek.Sunday) { } } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Generate(ByVal sender As Object, ByVal e As EventArgs) Dim publicHolidays = {New DateTime(2019, 1, 1), New DateTime(2019, 1, 26), New DateTime(2019, 3, 4), New DateTime(2019, 4, 6), New DateTime(2019, 4, 19), New DateTime(2019, 5, 1)} Dim start As DateTime = New DateTime(2019, 1, 1) For Each item In publicHolidays If item &lt;&gt; start AndAlso item.DayOfWeek &lt;&gt; DayOfWeek.Saturday AndAlso item.DayOfWeek &lt;&gt; DayOfWeek.Sunday Then End If Next End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/107974/Check-if-DateTime-is-Weekend-or-public-Holiday-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/107974/Check-if-DateTime-is-Weekend-or-public-Holiday-using-C-and-VBNet-in-ASPNet/Fri, 28 Jun 2019 03:38:41 GMT