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.Calculate Time between two Dates in RDLC Report using C# and VB.Net in ASP.Net<p>Hey <a class="username" rel="vail"> vail</a>,</p> <p>Please refer below sample</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:ScriptManager ID=&#34;ScriptManager1&#34; runat=&#34;server&#34;&gt; &lt;/asp:ScriptManager&gt; &lt;rsweb:ReportViewer ID=&#34;ReportViewer1&#34; runat=&#34;server&#34; Height=&#34;235px&#34; Width=&#34;565px&#34;&gt; &lt;/rsweb:ReportViewer&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using Microsoft.Reporting.WebForms; using System.Configuration; using System.Data.SqlClient;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data.SqlClient Imports Microsoft.Reporting.WebForms</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath(&#34;~/Report.rdlc&#34;); Orders dsOrders = GetData(&#34;select top 20 * from Orders WHERE OrderID IN (11090,11091)&#34;); ReportDataSource datasource = new ReportDataSource(&#34;DataSet1&#34;, dsOrders.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); } } private Orders GetData(string query) { string conString = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; SqlCommand cmd = new SqlCommand(query); using (SqlConnection con = new SqlConnection(conString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (Orders dsOrders = new Orders()) { sda.Fill(dsOrders, &#34;DataTable1&#34;); return dsOrders; } } } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not IsPostBack Then ReportViewer1.ProcessingMode = ProcessingMode.Local ReportViewer1.LocalReport.ReportPath = Server.MapPath(&#34;~/Report.rdlc&#34;) Dim dsOrders As Orders = GetData(&#34;select top 20 * from Orders WHERE OrderID IN (11090,11091)&#34;) Dim datasource As ReportDataSource = New ReportDataSource(&#34;DataSet1&#34;, dsOrders.Tables(0)) ReportViewer1.LocalReport.DataSources.Clear() ReportViewer1.LocalReport.DataSources.Add(datasource) End If End Sub Private Function GetData(ByVal query As String) As Orders Dim conString As String = ConfigurationManager.ConnectionStrings(&#34;constr&#34;).ConnectionString Dim cmd As SqlCommand = New SqlCommand(query) Using con As SqlConnection = New SqlConnection(conString) Using sda As SqlDataAdapter = New SqlDataAdapter() cmd.Connection = con sda.SelectCommand = cmd Using dsOrders As Orders = New Orders() sda.Fill(dsOrders, &#34;DataTable1&#34;) Return dsOrders End Using End Using End Using End Function</pre> <p><span style="text-decoration: underline;"><strong>Expression</strong></span></p> <pre class="brush: vb">=Format(Floor((DateDiff(&#34;n&#34;,Fields!ShippedDate.Value, Fields!RequiredDate.Value))/60),&#34;00&#34;) + &#34;:&#34; + Format(((DateDiff(&#34;n&#34;,Fields!ShippedDate.Value, Fields!RequiredDate.Value)) Mod 60),&#34;00&#34;)</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/tsktgfd.jpg" alt="" width="568" height="165" /></p>https://www.aspforums.net:443/Threads/119660/Calculate-Time-between-two-Dates-in-RDLC-Report-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/119660/Calculate-Time-between-two-Dates-in-RDLC-Report-using-C-and-VBNet-in-ASPNet/Wed, 23 Jan 2019 05:50:19 GMT