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 7178739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:58:49+00:00 2026-05-28T16:58:49+00:00

How can i substract 2 datetime in repeater? I want to substract 2 requestDates

  • 0

How can i substract 2 datetime in repeater?
I want to substract 2 requestDates and write to waitingTime.

       <td>
        <%#Eval("requestDates")%>
        </td>
        <td>
        <%#Eval("waitingTime")%>
        </td>

         I wanna get like 1 week 4 days 18 hours 47 minutes:>

        ID         Request_Dates                     Waiting_Time
        1      18.01.2012 09:54:38          6 days 20 hours 37 mins 13 sec
        2      11.01.2012 13:17:25                 19 hours 18 mins 47 sec
       ...            ....                                 ....

as you see waiting time = (id 1 request_dates) – (id 2 request_dates)
Thank you.

  • 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-05-28T16:58:50+00:00Added an answer on May 28, 2026 at 4:58 pm

    ONE SOLUTION

    You can create a method and call it in your html code, in this way:

     <td>
            <%# substraction(Eval("requestDates"),Eval("waitingTime"))%>
            </td>
    

    in the cs:

    public function substraction(....){}
    

    Only take into account that you have to cast the variables in the html and cs.

    ANOTHER SOLUTION
    I would replace the Eval with Literals, add an ItemDataBound event and in the method I would find the controls and assign the values, here I can get the values from the “e.Item” object and substract it easily.
    For example:

    <asp:Repeater ID="rp" runat="server" OnItemDataBound="Item_Bound">
    .....
    </asp:Repeater>
    
     void Item_Bound(Object sender, DataListItemEventArgs e)
          {
    
             MyObject theobject=(MyObject) e.Item.DataItem;
             if (e.Item.ItemType == ListItemType.Item || 
                 e.Item.ItemType == ListItemType.AlternatingItem)
             {
    
                // Retrieve the Label control in the current DataListItem.
                Label ltRequest = (Label)e.Item.FindControl("ltRequest");
              ltRequest.text=theobject.requestDates;
            ....
            /**HERE I CAN DO WHATEVER***/
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me how I can display a status message like 12 seconds
I would like to create a setter method for a datetime object so that
I get a datetime field, that's currently in the query as: SELECT DATE_FORMAT(x.date_entered, '%Y-%m-%d')
I have 2 DateTime objects. One which represents 2 days from now and the
I have a Sql view Im trying to write and I'd like to be
With this code: i.SpesaAlloggio = db.TDP_NotaSpeseSezB.Sum(p => p.Costo / (((DateTime)p.DayEnd) .Subtract((DateTime)p.DayStart).Days + 1)); I
I want to get two particular dates by using current date, let me explain
How can I get the duration in terms of minutes by subtracting a previous
In my script I need to make a cycle like this one: use DateTime;
How can I subtract two dates when one of them is nullable? public static

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.