473,466 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Create 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.Substract(fechaDos).Days

2.)

int desplazamientoFechaActual = fechaLaborable.DayOfYear -
fechaActual.DayOfYear;

3.) DateTime now = DateTime.Now;
DateTime seed = Convert.ToDateTime("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 1681
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.Substract(fechaDos).Days
2.)

int desplazamientoFechaActual = fechaLaborable.DayOfYear -
fechaActual.DayOfYear;

3.) DateTime now = DateTime.Now;
DateTime seed = Convert.ToDateTime("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
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 ...
26
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: ...
1
by: bradleyc | last post by:
How would you calculate the difference between two dates?
5
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,...
1
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...
3
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...
3
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.