473,513 Members | 2,684 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Days Count?

10 New Member
Hi,
I have two fileds
1. FromDate
2.ToDate

Days= FromDatetextbox.text – ToDateTextBox.text;

The result i want like
Days = 18/04/2008 - 22/04/2008;
Response.write(Days);
Result is : 4

How will i get this kind of result?
Apr 16 '08 #1
2 1015
DrBunchman
979 Recognized Expert Contributor
Hi pskvenkat,

You can calculate the difference, in days, between two dates using the following example. The Days property simply returns the number of whole days represented by the time difference.
Expand|Select|Wrap|Line Numbers
  1.  Dim a, b 
  2. Dim Days As Int16
  3. a = Date.Parse(FromDateTextBox.text)
  4. b = Date.Parse(ToDateTextBox.text)
  5. Days = (b - a).Days
  6.  
This is in VB but i'm sure you can convert it to C# if required without too much difficulty.

Hope this helps,

Dr B
Apr 16 '08 #2
pskvenkat
10 New Member
Thanks i got it,
code is like this

TimeSpan datediff = Convert.ToDateTime(TextBox2.Text) - Convert.ToDateTime(TextBox1.Text);

TextBox3.Text = datediff.ToString();
Apr 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
4645
by: Tom | last post by:
Please help. I need a quick little scrpit to place on a web page that will count how many days have passed since January 1, 1970. I have ZERO experience writing ANY scripts. Anyone have any...
5
14871
by: BlackFireNova | last post by:
I need to write a report in which one part shows a count of how many total records fall within the working days (Monday - Friday) inside of a (prompted) given date range, in a particular...
2
3404
by: David Mitchell | last post by:
I have tried using the following code to count the specific number of each weekday but get a compile error "User defined type not defined" which I think relates to the first line of the function: -...
9
1556
by: Frank | last post by:
I have a time saved in a time_t variable. I'd like to be able to display the number of days since then but can't find anything built-in that will help. Failing that I'd like to display the...
0
1075
by: santybanty20 | last post by:
sir,i have written the code for file uploading but it is very slow like it takas 2 to 3 minutes for 5 kb file and for 1 mb abt 20 minutes.so here is my code please help me for fast uploading also the...
9
21374
by: clintonb | last post by:
I'm looking for a way to calculate the number of days between two dates using standard C++ functions. Would it be as simple as just using the difftime() function and then dividing that result by...
5
3154
by: jjkeeper | last post by:
G'day, I'm currently working on an annual leave database for the company, so far so good, till they want the database to be able to identify public holidays and prevent reducing the employee's...
7
3211
by: Mike | last post by:
I have a routine that's calculating business days but its not counting the weekend days that are between the start date and end date. If my start date is 9/26/08 and my end date is 10/01/08, I...
9
11576
by: sha2484 | last post by:
I need help to count days between 2 dates,where i want to count the days between current date and registeration date.Here is the code that i have write but it only compare the days , it do not...
5
24525
FishVal
by: FishVal | last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL. So, let us say the problem is to calculate...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.