Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:26:23+00:00 2026-06-05T07:26:23+00:00

In my TimeIn.aspx File, I am displaying clock with following code: <div> <div> <asp:ScriptManager

  • 0

In my TimeIn.aspx File, I am displaying clock with following code:

<div>
    <div>
        <asp:ScriptManager runat="server" ID="ScriptManager1" />
        <br />

        <asp:UpdatePanel runat="server" ID="UpdatePanel1">
            <ContentTemplate>
                <asp:Label runat="server" ID="Label4" Text="Current Time: "/>
                <asp:Label runat="server" ID="Label2" />
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="1000" />
    </div>
    <br />

    <br />
    <asp:Button ID="Button1" runat="server" Text="Check In" OnClick="CheckIn" />
</div>

The clock works fine. Then in TimeIn.aspx.cs file, I have written CheckIn method:

protected void CheckIn(object sender, EventArgs e)
{
    TimeSpan currtime = TimeSpan.Parse(Label2.Text);
    int eid = Convert.ToInt32(Session["EID"]);
    DBClient = new DBConnection();
    DBClient.CheckIn(eid, currtime, DateTime.Now.Date.ToString());
    Response.Redirect("ECheckin.aspx");
}

In Database, the Datatype of CheckinTime column is Time(7).
When CheckIn event fires it gives exception on first line of TimeSpan.Parse because Label2.Text have time with time format added (AM/PM).
Sample value of Label2.Text is: 1:41:28 PM
Whats the best solution to deal with this situation? I really want to use Time datatype in sql server because later i will have to perform calculations on time field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:26:24+00:00Added an answer on June 5, 2026 at 7:26 am

    Timespan is basically difference between two times.

    Or we can say a stopwatch where value in stopwatch is time that have elapsed since when clock started and when clock stopped.

    It has nothing to do with AM or PM.

    Timespan = Date1 - Date2
    

    I guess the error that you are getting will be FormatException

    Your format of Label Text is DateTime that’s why AM/PM.

    Instead of Timespan try using DateTime instance

    like

    DateTime currtime = DateTime.Parse(Label2.Text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display time in a label. My code is: <asp:ScriptManager ID=ScriptManager1 runat=server
The .aspx: <asp:GridView ID=gvFirst runat=server AutoGenerateColumns=false AllowPaging=true ondatabound=gvFirst_DataBound > <Columns> <asp:BoundField DataField=ID HeaderText=ProductID/> <asp:BoundField
I have a table that has the following columns: GRVLID GRID Timein Timeout This
I run into similar codes like this all the time in aspx pages: <asp:CheckBox
Using SQL Server 2000 I want to get Table2.TimeIn Table2.TimeOut according to Table1.personid and
Using SQL Server 2000 Table1 ID Name, Date, TimeIn, TimeOut, DateIn, Dateout AEAA00294 Alexander
I want to create a method that takes two variables timeIn and timeOut and
i m using c# for first time in a asp.net website, in which i
I'm developing an Asynchronous Game Server using .Net Socket Asynchronous Model( BeginAccept/EndAccept...etc.) The problem
I am trying to output a table of IDNums + Name + Max(TimeOut-TimeIn). I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.