473,473 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

day-difference between 2 datetimes

hi,
how do I get the difference, in days, between two DateTime classes?
Sep 15 '06 #1
4 11423
Hi Daves,

Daves napisał(a):
hi,
how do I get the difference, in days, between two DateTime classes?
You'll need the TimeSpan.TotalDays.

sample:
TimeSpan ts=dateTime2.Subtract(dateTime1);
double daysDifference=ts.TotalDays.

With regards
Marcin
Sep 15 '06 #2
thx, exactly what was needed
"Marcin Grzębski" <mg***************@taxussi.com.plwrote in message
news:ee**********@news.supermedia.pl...
Hi Daves,

Daves napisał(a):
>hi,
how do I get the difference, in days, between two DateTime classes?

You'll need the TimeSpan.TotalDays.

sample:
TimeSpan ts=dateTime2.Subtract(dateTime1);
double daysDifference=ts.TotalDays.

With regards
Marcin

Sep 15 '06 #3
Hi,

instead of
ts = dateTime2.Subtract(dateTime1);

you als could say

ts = dateTime2 - dateTime1;

"Marcin Grzębski" <mg***************@taxussi.com.plschrieb im Newsbeitrag
news:ee**********@news.supermedia.pl...
Hi Daves,

Daves napisał(a):
>hi,
how do I get the difference, in days, between two DateTime classes?

You'll need the TimeSpan.TotalDays.

sample:
TimeSpan ts=dateTime2.Subtract(dateTime1);
double daysDifference=ts.TotalDays.

With regards
Marcin

Sep 15 '06 #4
Hi Christof,

You're right.
But i'll trying not using the class operators (overload),
since i leave C++ for Java.
:-)

Cheers!
Marcin

Christof Nordiek napisał(a):
Hi,

instead of
ts = dateTime2.Subtract(dateTime1);

you als could say

ts = dateTime2 - dateTime1;

"Marcin Grzębski" <mg***************@taxussi.com.plschrieb im Newsbeitrag
news:ee**********@news.supermedia.pl...
>Hi Daves,

Daves napisał(a):
>>hi,
how do I get the difference, in days, between two DateTime classes?
You'll need the TimeSpan.TotalDays.

sample:
TimeSpan ts=dateTime2.Subtract(dateTime1);
double daysDifference=ts.TotalDays.

With regards
Marcin

Sep 15 '06 #5

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

Similar topics

1
by: Steve Fitzgerald | last post by:
The below code works greate for displaying a monthly calendar, but I'm trying to modify it so that it only shows a seven day week calendar. What should I do to modify it. <?php function...
2
by: patrick delifer | last post by:
I am binding some data to a calendar control. Since I don't want to return all the Data from the DB, I would like to return only the data for the current view of the calendar. The calendar has...
4
by: laredotornado | last post by:
Hi, Using PHP 4, if I have a date, what is a function I could use to give me a date that represents the first day of that month? For example, if my date were "3/19/2006 8:00", I would want my...
3
by: jethro_uk | last post by:
Hi all, I'm having a hard time with the Day() function. Basically, it appears to be picking and choosing which part of a date string it uses to return the result ... heres some code : ...
6
by: aarklon | last post by:
Hi folks, I found an algorithm for calculating the day of the week here:- http://www.faqs.org/faqs/calendars/faq/part1/index.html in the section titled 2.5 what day of the week was 2 august...
7
by: Gucci | last post by:
<?php /** * check ine year is a leap year, and return the month day array * * @param int $year **the year must bigger than zero** * @return array */ function is_leap_year($year){...
8
by: ilikenwf | last post by:
I get 27 errors when I try to compile, none of which make sense to me, since the code looks good. I have my header file included, and all of my function definitions are in the class contained in the...
5
by: chaos | last post by:
Hi , I stuck in my project as i face a problem How to show the available time of the venue when i select the day?? Need to connect to the database to find out the available time of the venue on...
5
by: madman228 | last post by:
Hi guys I'm new to java and have no idea how what to do with this problem. If someone can help me get started with this program it'll be really appriciated. The problem is: Design and implement...
2
by: madman228 | last post by:
Hi guys I'm new to java and have no idea how what to do with this problem. If someone can tell me weather I'm on the right track or not that will be great. Any help will be appreciated. The problem...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
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...
1
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: 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
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 ...
0
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...

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.