Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From Date To Date Return Total Hours ASP.NET FORM

Status
Not open for further replies.

mhamlett

Programmer
Oct 20, 2014
10
US
Below is my code and it simply renders 2 textboxes and a button. The first textbox value will be "FROM DATE" and the second textbox value will be "TO DATE". The database table has a column for Hours and a Column for Date. When the end user submits their entry, I would like to return the total hours between the two dates provided. I'm having trouble researching this scenario as it appears to be more complex than I imagined it would be, any help would be gratefully appreciated!

Thanks






////////////////////////////////////////CODE///////////////////////////////////////////////////

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="<head runat="server">
<title></title>

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>

<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>

<script>
$(function () {
$("#datepicker2").datepicker();
});
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<p>From
<asp:TextBox ID="datepicker" runat="server"></asp:TextBox>
</p>
<p>&nbsp;</p>
<p>To <asp:TextBox ID="datepicker2" runat="server"></asp:TextBox>
</p>
<asp:Button ID="Button1" runat="server" Text="Button" />

</div>
</form>
</body>
</html>
 
I have excatly the same situation on a time sheet entry site, what I did is created an SQL function that calculates the differential and give the result on the post back. The SQL is very easy to write using the DATEDIFF() function
 
Can you give an example using my layout or any example at all with code behind?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top