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.
ONE SOLUTION
You can create a method and call it in your html code, in this way:
in the cs:
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: