473,657 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

difference (in days) of two dates


Hi, misters

which the best method for get the difference (in days) of two dates. The
hour (hh:mm) don't mind, would be 00:00 for all dates.
1.)
fechaUno.Substr act(fechaDos).D ays

2.)

int desplazamientoF echaActual = fechaLaborable. DayOfYear -
fechaActual.Day OfYear;

3.) DateTime now = DateTime.Now;
DateTime seed = Convert.ToDateT ime("2006/01/01");

TimeSpan diff = now - seed;
int result = diff.TotalDays;

4.) Another ??

Any help about it ? Thanks in advance. Greetings.

--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net
www.trabajobasura.com/solusoft

Aug 23 '07 #1
1 1694
Hi, misters
>
which the best method for get the difference (in days) of two dates.
The hour (hh:mm) don't mind, would be 00:00 for all dates.

1.)
fechaUno.Substr act(fechaDos).D ays
2.)

int desplazamientoF echaActual = fechaLaborable. DayOfYear -
fechaActual.Day OfYear;

3.) DateTime now = DateTime.Now;
DateTime seed = Convert.ToDateT ime("2006/01/01");
TimeSpan diff = now - seed;
int result = diff.TotalDays;
4.) Another ??

Any help about it ? Thanks in advance. Greetings.
method 2 gives a wrong answer when the dates are in different years.
methods 1 & 3 return the same results (when you use the same dates)

Hans Kesting
Aug 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2121
by: Alex | last post by:
I need to calculate the number of days between two dates formatted yyyymmdd. Besides creating a whole date class, is there a simpler method of doing it? for example: 20050203 - 20050201 = 2 right now what I have is string sdate1 = "20050203"; string sdate2 = "20050201"; string date = date1 .substr(6.2);
26
4397
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: starttime = Date.parse("Aug 10,2003, 07:07") sdt = new Date(starttime)
1
21361
by: bradleyc | last post by:
How would you calculate the difference between two dates?
5
2142
by: deebees | last post by:
Hi everyone - I've been using a simple Access 2000 database table for some time for data for animal breeding programme. Every breeding animal has an individual record for each time there is a birth, showing the number born ... and so on. What I want to be able to do is to work out the amount of time - say as a fraction of a year - between the first and the last birth, bearing in mind that there may be anything from 3 to 10 births for any...
1
2032
by: sharathragunathan | last post by:
HI, I have an Access novice and I have a question.I have a form that has a request date that a user enters. What I need is when you click on a command button, say Elapsed Time, it should give (via messge box or as data in a text box) the difference between the request date and the current day. Eg : Request Date- 02/02/2003 and assuming current date is 02/02/2007 Elapsed Time - 4 years.
3
1572
by: Davide | last post by:
Hi all. I'm looking in php.net a function that helps me to work with date. I need to build a script wich can calulate the difference from a specific date "2007-03-01" to current date. I'm thinking about unix epoch, is it the correct way? example:
3
1789
by: prashantkuppa | last post by:
hi, iam struggling with difference between two dates of format type dd/mm/yyyy i need difference between two dates olddate(dd/mm/yyyy) - newdate(dd/mm/yyyy) and this should be in java script please helpme thanking you
0
8421
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
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7354
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...
1
6177
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
1971
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.