Click here to Skip to main content
15,905,071 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to substrat time from two textboxes and store into another textbox in asp.net
Posted
Updated 20-Jul-12 2:33am
v2
Comments
[no name] 20-Jul-12 8:31am    
Using the TimeSpan class might help.
bbirajdar 20-Jul-12 8:35am    
@amritbdk.. Isnt this link surprising ? click me

1 solution

You can use TimeSpan.

Here are example for that
C#
DateTime dt1= DateTime.Now; // select Date 1
DateTime dt2= DateTime.Now.AddDays(20);  // select Date 2


TimeSpan ts = dt2 - dt1; // Substract Date 2 to Date 1

Textbox1.Text= ts.Days; // Get The Total Days Difference

Here it gives 20 for days different
 
Share this answer
 
v3
Comments
bbirajdar 20-Jul-12 8:40am    
Dear Little Coder.. We don't encourage questions asking for code and we don't provide code to the OPs in this forum. Spoon feeding is not encouraged. We resolve the 'issues' when the OP shows his 'efforts' and is facing some difficulty.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900