473,671 Members | 2,340 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.t ext;

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 1017
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.ToDateT ime(TextBox2.Te xt) - Convert.ToDateT ime(TextBox1.Te xt);

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

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

Similar topics

8
4658
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 suggestions? As for what is displayed on the screen, I just want it to say: Today is: 12578 (or however many days have passed since that date.)
5
14886
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 geographical region. I have written a query which prompts the user for the start and end dates. It also filters for entries which pertain to the particular geographical region. I'm not sure where to go from here.
2
3413
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: - Public Function HowManySpecificDays(StartDate As Date, EndDate As Date) As DayCounts and specifically the word "DayCounts" Can anyone help?
9
1572
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 date (only the date) that corresponds to the saved time_t variable. Thanks for any help
0
1081
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 code for download is given but it has some error help me in this because i have to submit after 3 days...help <html> <body> <% String str=(String)session.getAttribute("cn"); //out.println(str); if(str==null) { %>
9
21381
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 the number of seconds in a day? - Clint
5
3164
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 balance if the application overlaps with the holiday. I'm using access 2000. Here's what I have so far. tblMainProfile - contains employee's profile EmployeeID <== Pkey Name Date of Birth .. tblLeaveApply - link to tblMainProfile by...
7
3218
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 should see 4 business days and 2 weekend days. How can I get that result? I'm getting 4 business days but its not counting the weekend days?
9
11584
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 compare the month and the year, where it will return 0 if the day of the second date is the same as the first date even the month or year are different, plz help me... my code: public static int dayDiff(java.sql.Date date1, java.sql.Date date2)throws...
5
24539
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 business days count which is defined as count of days (optionally inclusive in the current implementation) excluding weekend days and holidays. Let us say periods to calculate are stored in table associated with contacts. keyPeriodID -...
0
8473
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2808
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 we have to send another system
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.